Subject | Min and Max and Indexes |
---|---|
Author | Alexander Tabakov |
Post date | 2003-04-15T13:35Z |
Hi,
I have a query like this running in a SP:
select phone_code, phone_number
from tbl_phone_2
where contact_id = (select min(contact_id) from contact_phone where party_id = :party_id)
into :phone_code, :phone_number;
So, there is an ASC index in table: "contact_phone" on contact_id
which is actually the table key. This query executes for about 40 sec.
with around 100K phones.
If I change the "min(contact_id)" to: "max(contact_id)" then it executes
for 2,5 sec.
I know it has something to do with the ascending index but I am not
sure.
Could you help me?
--
Best regards,
Alexander mailto:saho@...
I have a query like this running in a SP:
select phone_code, phone_number
from tbl_phone_2
where contact_id = (select min(contact_id) from contact_phone where party_id = :party_id)
into :phone_code, :phone_number;
So, there is an ASC index in table: "contact_phone" on contact_id
which is actually the table key. This query executes for about 40 sec.
with around 100K phones.
If I change the "min(contact_id)" to: "max(contact_id)" then it executes
for 2,5 sec.
I know it has something to do with the ascending index but I am not
sure.
Could you help me?
--
Best regards,
Alexander mailto:saho@...