Subject | Re: [IBO] Interbase index question.... |
---|---|
Author | Svein Erling Tysvær |
Post date | 2001-07-20T08:42:53Z |
>so, would it be best to create 5 different indexs since I am going to useNo, that's too many indexes. If you have an index (PIN, CUSTID) that will
>these indexes commonly ??
>I.E.
>CUSTID
>CUSTID+PIN
>CUSTID+ANI
>PIN
>ANI
cover both CUSTID+PIN and only PIN. Which indexes you ought to create
depends on how often each value of a given field exists in the table. If
they are relatively rare, I would only use three indexes - one on CUSTID,
one on (PIN, CUSTID) and one on (ANI, CUSTID). If even combinations have
plenty of repetitions, you should add to your index the primary key as the
last field to make each entry in the index as unique as possible (too much
repetitions may make updates slow). Also, you should think of how often you
issue each of your calls. I find that in Interbase it is more often a
problem of too many indexes than too few. E.g. if you issued
SELECT * FROM CALL_LOG WHERE CUSTID='123456' AND PIN='1235'
and had a separate index on each of the fields only (i.e. no combined (PIN,
CUSTID) index, then Interbase would use two indexes and that would slow
down your query a lot. In such circumstances I do the following to reduce
to only using one index:
SELECT * FROM CALL_LOG WHERE CUSTID='123456' AND (PIN='1235' or 2=3)
This makes it impossible to use an index for PIN.
HTH,
Set