Subject | Re: [ib-support] View performance |
---|---|
Author | Ivan Prenosil |
Post date | 2003-04-14T22:46:34Z |
> ...Computed field will be computed only when you select it. E.g.
> CREATE VIEW V (
> pk,
> data1,
> data2,
> data3,
> data4,
> ...
> dataN
> ) as
> select
> T.pk,
> (select data1 from spGetData1(T.pk)),
> (select data2 from spGetData2(T.pk)),
> (select data3 from spGetData3(T.pk)),
> ...
> (select dataN from spGetDataN(T.pk))
> )
> from T;
> ...
>
> I was going to implement data1,data2,etc as a COMPUTED FIELD, but I
> changed my mind since some of the calculations in the storedprocs can be
> time consuming. As far as I understand it, using a computed field will
> incur a penalty on every access to the record.
CREATE TABLE T (
pk INTEGER ...,
data1 COMPUTED (select data1 from spGetData1(T.pk)),
data2 COMPUTED (select data1 from spGetData2(T.pk)) );
SELECT pk, data1 FROM T;
-> only spGetData1(T.pk) will be computed, not spGetData2(T.pk).
Ivan
http://www.volny.cz/iprenosil/interbase