Subject Re: Subset query
Author Svein Erling Tysvær
Hi Willy!

My problem with your question is that the query you supplied seems
like a query that should execute quickly. I expect both of the
INDEXEDFIELDs to be TIMESTAMPs, and that using an index on
INDEXEDFIELD1 is useful, whereas the index on INDEXEDFIELD2 ought to
be avoided. Aages suggestion using INDEXEDFIELD2+0 prevents the
optimizer from using an index on INDEXEDFIELD2, more or less like you
asked for.

If it still is slow, I'd recommend you to show us the entire SQL (is
this the entire SQL or only a subselect?), the generated plan and some
information about index selectivity. Myself, I prefer using BETWEEN
rather than >= and <=, but I think that is just my preference and not
important.

Set

--- In firebird-support@yahoogroups.com, "willy_metra" wrote:
> > No, I cannot unless you tell me what you're trying to do.
>
> Sure, here we go...
>
> I'm trying to do:
>
> select
> *
> from
> TABLENAME
> where
> (INDEXEDFIELD1 > '8.3.2006 00:00:00' and INDEXEDFIELD1 < '8.3.2006
> 00:10:00') and INDEXEDFIELD2 < '8.3.2006 00:00:00'
>
> Both where-fields are indexed, but the problem is that the first
> where-predicate is done very quickly due to short condition range,
> it's just 10 mins. But the second one is very long, cuz it's going
> through the whole db. So i'm trying select the first subset via the
> first where-predicate and than apply the second where predicate on
> the selected subset.
>
> Thank you for any kind help.