On 09/04/13 02:44 -0700, Marc Rechté wrote:
> For instance, if we consider the General Ledger report, and the simple 
> table scan on account_move:
> 
>         clause = [
>             ...,
>             ('period.fiscalyear.company', '=', data['company']),
>             ]
>         return Move.search(clause,
>                 order=[('date', 'ASC'), ('id', 'ASC')])
> 
> The extra AND clause generated by 'period.fiscalyear.company', '=', 
> data['company'] seems to be:
> 
>     AND ("account_move"."period" IN (SELECT "account_period".id AS id FROM 
> "account_period" WHERE (("account_period"."fiscalyear" IN (SELECT 
> "account_fiscalyear".id AS id FROM "account_fiscalyear" WHERE 
> (("account_fiscalyear"."company" = 1)) AND ("account_fiscalyear".id IN 
> (SELECT "account_fiscalyear".id AS id FROM "account_fiscalyear" WHERE 
> (((("account_fiscalyear"."company" = 1))) AND true)))))) AND 
> ("account_period".id IN (SELECT "account_period".id AS id FROM 
> "account_period" WHERE (((("account_period"."fiscalyear" IN (SELECT 
> "account_fiscalyear".id AS id FROM "account_fiscalyear" WHERE 
> (("account_fiscalyear"."company" = 1)))))) AND true)))))) 
> 
> I am not sure this is efficient, but for sure it is unreadable.

It doesn't have the purpose to be readable.


> Not to talk about the case when such query needs to be related to other 
> tables (that could also requires such indirection).

And what? Relational database are designed for this work.

> Having company field in the move table would probably zap this extra clause 
> wouldn't it ?

Not completly because there will still be check about access right.
Once there is data duplication, there is data integrity errors.
There is already duplication because accounts have a company and
fiscalyears have.

Finally, the design of the Tryton database is not done for report
purpose but for operational use. Tryton provides the mimimal reports for
operation but the goal is not to provide a schema for BI.

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgprayCMJmfkL.pgp
Description: PGP signature

Reply via email to