Subject | Re: Avoid using index in sql |
---|---|
Author | Svein Erling |
Post date | 2004-02-09T09:37:25Z |
Just OR with something always evaluating to false. E.g. if I had a
query like:
SELECT *
FROM MyTable
WHERE Age BETWEEN 15 and 75
AND BirthDate BETWEEN '01.01.1900' AND '31.12.1999'
or anything similar where indexes would slow things down compared to
do a natural, I would change it to
SELECT *
FROM MyTable
WHERE (Age BETWEEN 15 and 75
AND BirthDate BETWEEN '01.01.1900' AND '31.12.1999') OR 1=0
Since the optimizer does not have any index for constants, there is no
way for it to index the query (well, unless Arno has made the
optimizer realize that constant comparisons only need to be evaluated
once).
HTH,
Set
query like:
SELECT *
FROM MyTable
WHERE Age BETWEEN 15 and 75
AND BirthDate BETWEEN '01.01.1900' AND '31.12.1999'
or anything similar where indexes would slow things down compared to
do a natural, I would change it to
SELECT *
FROM MyTable
WHERE (Age BETWEEN 15 and 75
AND BirthDate BETWEEN '01.01.1900' AND '31.12.1999') OR 1=0
Since the optimizer does not have any index for constants, there is no
way for it to index the query (well, unless Arno has made the
optimizer realize that constant comparisons only need to be evaluated
once).
HTH,
Set
--- In firebird-support@yahoogroups.com, "sivram_kr" wrote:
> Thanks Brinkman..
> Is there any other way?
>
> Regards,
> Siva
>
> How can i avoid using index in my sql?