Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slow select 2

Status
Not open for further replies.

chrissie1

Programmer
Aug 12, 2002
4,517
BE
I have a select on an oracle database


Code:
SELECT ZK_NR, ...
FROM NIC.PIMS_ZAKEN Z 
WHERE Z.ZK_NR = :ZK_NR

ZK_NR being the Primary key

this one takes 0.1 seconds

and then I have this


Code:
SELECT ZK_NR, ... 
FROM NIC.PIMS_ZAKEN 
WHERE OUDE_REF_NICC IS NULL 
AND REDEN_ANNULATIE IS NULL

wich takes approx. 2.5 seconds to return anything. Both selects return the same record. And I (or they) have an index on OUDE_REF_NICC not on REDEN_ANNULATIE.

NIC is the schema and PIMS_ZAKEN is a simple view.

Does anybody have any idea how to make this thing go faster?

BTW I made them put the index on OUDE_REF_NICC this morning in an attempt to make it faster. But it din't help.


Christiaan Baes
Belgium

"My new site" - Me
 
Searching for NULL is always a full table scan as NULL is never indexed.

Assuming OUDE_REF_NICC is normally a positive integer, if you make it -1 at creation and then assign it a positive value once it is known, that will index better than creating it as NULL.

I tried to remain child-like, all I acheived was childish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top