As a follow up to What columns generally make good indexes? where I am attempting to know what columns are good index candidates for my query ?
using ROWNUM for my query, which columns I should add to an index to improve performance of my query for oracle Database ? I already create and index on startdate and enddate .
SELECT
ID,
startdate,
enddate,
a,
b,
c,
d,
e,
f, /*fk in another table*/
g /*fk in another table*/
FROM tab
WHERE (enddate IS NULL ) AND ROWNUM <= 1;
below is the plan table output:
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
Plan hash value: 3956160932
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 64 | 2336 (2)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
|* 2 | TABLE ACCESS FULL| tab | 2 | 64 | 2336 (2)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM<=1)
2 - filter("tab"."enddate " IS NULL)
thanks for help.