开发者

index for `where wakeup_time < sysdate`

开发者 https://www.devze.com 2022-12-23 20:50 出处:网络
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.Co

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消