Subject | Re: [ib-support] Index performance question |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2003-05-12T14:22:42Z |
Sorry for not answering your question, I simply do not know the answer.
Still, I have a couple of comments:
1) If your field almost always has the same value, then don't bother
indexing it unless your queries are seaching for records that do not have
this common value.
2) The order of fields in an index may determine if the index can be used
in other circumstances or not. E.g. if you have an index (field1, field2),
then this index can be used in the statement SELECT * FROM ATABLE WHERE
FIELD1 = :AVALUE, but not in SELECT * FROM ATABLE WHERE FIELD2 = :AVALUE. I
usually think of such circumstances when determining the order of the
fields in an index, not whether there is any speed difference as to which
field to mention first if both are specified in the WHERE clause (if there
is a difference, I would expect it to be minimal).
HTH,
Set
At 13:51 12.05.2003 +0000, you wrote:
Still, I have a couple of comments:
1) If your field almost always has the same value, then don't bother
indexing it unless your queries are seaching for records that do not have
this common value.
2) The order of fields in an index may determine if the index can be used
in other circumstances or not. E.g. if you have an index (field1, field2),
then this index can be used in the statement SELECT * FROM ATABLE WHERE
FIELD1 = :AVALUE, but not in SELECT * FROM ATABLE WHERE FIELD2 = :AVALUE. I
usually think of such circumstances when determining the order of the
fields in an index, not whether there is any speed difference as to which
field to mention first if both are specified in the WHERE clause (if there
is a difference, I would expect it to be minimal).
HTH,
Set
At 13:51 12.05.2003 +0000, you wrote:
>Let's supose i have a table with a pk and two more fields, field1
>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?