Subject | Re: [firebird-support] computed lookup |
---|---|
Author | Helen Borrie |
Post date | 2010-02-27T22:34:27Z |
At 08:43 PM 27/02/2010, you wrote:
This isn't how computed columns are meant to be used, by the way. It is an example of "Just because you can, doesn't mean you should"). There is just too much that can go wrong in data and leave you with an unrestorable database.
For a happy life, restrict your used of COMPUTED BY columns to literal or constant values and expressions involving columns within the same record.
If you have to design a relation that has dependencies on other tables, create a view instead, using joins in preference to subqueries.
./heLen
>If have several computed columns which select values from the same table. example:It does a separate subquery for each computed column.
>
> lu_branch_id_name varchar(120) computed by
> ((select branch.name from branch where branch.id = sos_batch.branch_id)),
> lu_branch_id_accnr varchar(120) computed by
> ((select branch.accnr from branch where branch.id = sos_batch.branch_id))
>
>Does the optimizer select the branch table only once or does it do a select for each computed column?
This isn't how computed columns are meant to be used, by the way. It is an example of "Just because you can, doesn't mean you should"). There is just too much that can go wrong in data and leave you with an unrestorable database.
For a happy life, restrict your used of COMPUTED BY columns to literal or constant values and expressions involving columns within the same record.
If you have to design a relation that has dependencies on other tables, create a view instead, using joins in preference to subqueries.
./heLen