Hi,
I have a very large table with over 1000 records and 200 columns. When I try to retreive records matching some criteria in the WHERE
clause using SELECT
statement it takes a lot of time. But most of the time I just want to select a single record that matches the criteria in the WHERE
clause rather than all the records.
I guess there should be a way to select just a single record and exit which would minimize the retrieval time. I tried ROWNUM=1
in the WHERE
clause but it didn't really work because I guess the engine still checks all the records even after finding the first record matching the WHERE
criteria. Is there a way to optimize in case if I want to select just a few records?
Thanks in advance.
Edit:
I am using oracle 10g. The Query looks like,
Select *
from Really_Big_table
where column1 is NOT NULL
and column2 is NOT NULL
and rownum=1;
This seems to work slower than the version without rownum=1;