Subject | Re: [ib-support] Index performance question |
---|---|
Author | Arno Brinkman |
Post date | 2003-05-12T17:27:20Z |
Hi,
----------------
SELECT * FROM ATable
WHERE
Field1 = <constant> and Field2 = <constant>
Doesn't matter which index the optimizer will use
----------------
SELECT * FROM ATable
WHERE
Field1 >= <constant> and Field2 = <constant>
Or any other greater than (or equal), less than (or equal) on field1.
The optimizer will choose your own created index (field2,field1), because
this will be faster (when using the PK index here then field2 is useless).
----------------
SELECT * FROM ATable
WHERE
Field1 = <constant> and Field2 < <constant>
Or any other greater than (or equal), less than (or equal) on field2.
The optimizer will choose the Primary Key.
----------------
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
See you at the First European Firebird Conference May 19-20 in Fulda,
Germany
http://www.firebird-conference.com
> Let's supose i have a table with a pk and two more fields, field1Depends on which criteria you have in your query (with Firebird 1.5).
> and field2, where field1 has almost always the same value for all
> records and field2 has more variations.
>
> Is there some performance difference if i create an index using
> (field2, field1) against (field1, field2), supposing i will make a
> query using these two fields in the criteria?
----------------
SELECT * FROM ATable
WHERE
Field1 = <constant> and Field2 = <constant>
Doesn't matter which index the optimizer will use
----------------
SELECT * FROM ATable
WHERE
Field1 >= <constant> and Field2 = <constant>
Or any other greater than (or equal), less than (or equal) on field1.
The optimizer will choose your own created index (field2,field1), because
this will be faster (when using the PK index here then field2 is useless).
----------------
SELECT * FROM ATable
WHERE
Field1 = <constant> and Field2 < <constant>
Or any other greater than (or equal), less than (or equal) on field2.
The optimizer will choose the Primary Key.
----------------
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
See you at the First European Firebird Conference May 19-20 in Fulda,
Germany
http://www.firebird-conference.com