Subject | Re: [firebird-support] Re: SQL Performance problem |
---|---|
Author | Helen Borrie |
Post date | 2004-11-24T01:39Z |
At 11:59 PM 23/11/2004 +0000, you wrote:
then the indexes are used. Read on...
views that convert natural columns into derived columns, by way of
expressions and, by extension, any SQL constructs by which you separate the
output from the underlying data, such as DISTINCT and GROUP BY.
during execution of the SP. But indexes are not used on the
output...hence, don't design selectable SPs with the intention of using
WHERE or ORDER BY clauses as part of the invocation call. Use input
parameters for determining search criteria; and perform ordering as part
of the execution of the SP.
./heLen
> > I have just solved the problem by doing the following ....Not true. If the view outputs indexed columns from the underlying tables,
> >
> > ORIGINAL SQL
> >
> > SELECT SupOrdrRef, OrderNo, OrderDate, Comment, DelAddr, PtdFlag,
>sEntityRef
> > FROM SupplyOrder WHERE EntityRef = 8 AND SupOrdrRef IN (SELECT
>DISTINCT SupOrdrRef FROM SupplyLine WHERE SupTranRef IS Null AND
>PackSlpRef IS Null AND CancelFlag = 'F' );
> >
> > FIX
> >
> > Create a View
> >
> > CREATE View TEST2 (SupOrdrRef) AS
> > SELECT DISTINCT SupOrdrRef FROM SupplyLine WHERE CancelFlag = 'F'
>AND SupTranRef IS Null AND PackSlpRef IS Null
> >
>
>
>Just be aware that views don't seem to use underlying table indexes
>even if they are available.
then the indexes are used. Read on...
>We found an issue a while back where someWhere the underlying fields' indexes become unavailable is where you define
>reports openned within seconds at our office, but onsite where there
>was a lot more data, they were sluggish.
>
>Running IBPlanalyzer, you can see that any query on a view wont take
>advantage on an index on a field of that view, and so it suffers big
>performance penalties with lots of data.
views that convert natural columns into derived columns, by way of
expressions and, by extension, any SQL constructs by which you separate the
output from the underlying data, such as DISTINCT and GROUP BY.
>We now use stored proceduresInternally, yes. Searched selects, joins, updates, etc. will use indexes
>for a lot of things, as they can be made to use the underlying index.
during execution of the SP. But indexes are not used on the
output...hence, don't design selectable SPs with the intention of using
WHERE or ORDER BY clauses as part of the invocation call. Use input
parameters for determining search criteria; and perform ordering as part
of the execution of the SP.
./heLen