tags:

views:

33

answers:

2

Hi

For most records this field is null. I need to wake up only some records.

The table is very big and I want to know which records to wake up. I don't want database to seek every row. Could you show me your idea?

A: 

Why don't you just create an index on wakeup_time? Also, you may fill it with a far away date by default, like 3000-01-01.

Agree with the index on wakeup_time. Disagree with the 'far away' default as Oracle doesn't index null values so an index on a column with lots of nulls will be small whereas an index on a column with lots of default values will be large.
Gary
+1  A: 

Create an ordinary index on just (WAKEUP_TIME). Only the rows where WAKEUP_TIME is not null will be stored in the index. When WAKEUP_TIME is updated to NULL, the entry will be removed from the index, so the index will be the most efficient way of finding all the rows that match your predicate.

Jeffrey Kemp