Subject | Re: slow: "select first(1) * from table where partnumber >= :search order by partnumber" |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-06-22T12:37:35Z |
--- In firebird-support@yahoogroups.com, Gunther wrote:
"select l1.REF from lagerkarte l1 Where ((l1.BESTELLNR>:P1) or
(l1.BESTELLNR=:P1 and l1.REF>:P2)) and not exists(
select * from lagerkarte l2 where ((l2.BESTELLNR>:P1) or
(l2.BESTELLNR=:P1 and l2.REF>:P2)) and
((l2.bestellnr < l1.bestellnr) or
(l2.bestellnr = l1.bestellnr and l2.ref < l1.ref)))"
Does this execute any quicker? And do you understand what it does? (I
consider readability to be more important than speed in many cases.
Set
> Only a single index on the partnumber column.Try to modify a bit:
> The plan looks like this:
> Plan
> PLAN (table ORDER IX_table_partnumber)
>
> Adapted Plan
> PLAN (table ORDER IX_table_partnumber)
>
>
> To be precise I'm trying to emulate single record displays and the
> movement of a sequentiel pointer through a sorted column.
> My exact sql for a "next" is:
> "select first(1) REF from lagerkarte Where ((BESTELLNR>:P1) or
> (BESTELLNR=:P1 and REF>:P2)) Order by BESTELLNR,REF"
"select l1.REF from lagerkarte l1 Where ((l1.BESTELLNR>:P1) or
(l1.BESTELLNR=:P1 and l1.REF>:P2)) and not exists(
select * from lagerkarte l2 where ((l2.BESTELLNR>:P1) or
(l2.BESTELLNR=:P1 and l2.REF>:P2)) and
((l2.bestellnr < l1.bestellnr) or
(l2.bestellnr = l1.bestellnr and l2.ref < l1.ref)))"
Does this execute any quicker? And do you understand what it does? (I
consider readability to be more important than speed in many cases.
Set