Subject | Re: INDEXes for a Query |
---|---|
Author | Svein Erling |
Post date | 2004-03-18T08:26:56Z |
--- In firebird-support@yahoogroups.com, Uwe Oeder wrote:
One option that occationally can be useful, is to have separate fields
like UPPER_WPName and UPPER_WPDescription which you index and populate
through triggers. However, such indexes cannot be used in your case,
since you are using '%oeder%' and not 'oeder%' or STARTING 'oeder', i.
e. you do not know the start of the string.
I'm not certain whether Firebird 1.5 has implemented expression
indexes yet, it probably would not help you much since I expect the
result set to be small, but an expression index on [W.CityName || '('
|| W.CityDiallingCode || ')'] could help marginally on the sorting.
Sorry, but indexes are only useful for comparison with the values of
the index itself where the beginning (of strings) or range is known.
HTH,
Set
> I have the following query which I need to optimize as it getsFor this query, the only index that can be of any use is on CityVBSQ.
> called a lot.
>
> 'SELECT W.WPOrder , W.CityName || '(' || W.CityDiallingCode || ')'
> AS
> CityName , W.WPIDSQ , W.WPVBSQ , W.WPName , W.WPDescription , W.
> WPLevel , W.CityVBSQ
> FROM Windler W
> WHERE UPPER(W.WPName) LIKE UPPER('%oeder%')
> AND
> UPPER(W.WPDescription) LIKE UPPER('%kwe%')
> AND
> W.CityVBSQ IN (200) ORDER BY 2 , 1
One option that occationally can be useful, is to have separate fields
like UPPER_WPName and UPPER_WPDescription which you index and populate
through triggers. However, such indexes cannot be used in your case,
since you are using '%oeder%' and not 'oeder%' or STARTING 'oeder', i.
e. you do not know the start of the string.
I'm not certain whether Firebird 1.5 has implemented expression
indexes yet, it probably would not help you much since I expect the
result set to be small, but an expression index on [W.CityName || '('
|| W.CityDiallingCode || ')'] could help marginally on the sorting.
Sorry, but indexes are only useful for comparison with the values of
the index itself where the beginning (of strings) or range is known.
HTH,
Set