Board index » delphi » IB & Indexes

IB & Indexes

I have a table with a Primary Key consisting of 2 columns, CALL_ID & CALL_TYPE.  50% of the select statements I run on this table pull back rows based on CALL_ID only i.e.

select *
from CALL_TABLE
where CALL_ID = :call_id

If I created an index on CALL_ID would this query run faster?
Or does this query use the primary key index?

 

Re:IB & Indexes


Stephen,

1) This question would be more suitable in
borland.public.interbase.general

2) I would guess that IB will use the PK index, but you can easily check
by running a sample query in IbConsole and look at the Plan tabsheet. If
you see 'natural' somewhere it means 'tablescan'.

3) For more advanced analysis see http://delphi.weblogs.com/IBPLANalyzer

-hh-

Quote
<Stephen Froude Stephen> wrote in message news:3d47a28b$1_2@dnews...

> I have a table with a Primary Key consisting of 2 columns, CALL_ID &

CALL_TYPE.  50% of the select statements I run on this table pull back
rows based on CALL_ID only i.e.
Quote

> select *
> from CALL_TABLE
> where CALL_ID = :call_id

> If I created an index on CALL_ID would this query run faster?
> Or does this query use the primary key index?

Re:IB & Indexes


The query should use the primary index. To make sure, run the query in
IBConsole and look at the query plan.

On 31 Jul 2002 01:40:43 -0700, "Stephen Froude" Stephen wrote:

Quote

>I have a table with a Primary Key consisting of 2 columns, CALL_ID & CALL_TYPE.  50% of the select statements I run on this table pull back rows based on CALL_ID only i.e.

>select *
>from CALL_TABLE
>where CALL_ID = :call_id

>If I created an index on CALL_ID would this query run faster?
>Or does this query use the primary key index?

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Other Threads