开发者

SQL - Select all rows added yesterday efficiently

开发者 https://www.devze.com 2023-01-17 17:01 出处:网络
I want to select all of the rows added to a table which were added \"yesterday\" i.e. the day before whenever I choose to run the query.

I want to select all of the rows added to a table which were added "yesterday" i.e. the day before whenever I choose to run the query.

At the moment my query looks like this:

SELECT row_date (etc)
WHERE  row_date >= trunc(sysdate-1)
       and row_date < truc(sysdate);

Is there a more efficient (and, hopefully, readabl开发者_StackOverflow社区e) way of achieving this?

Cheers,

Pete


That query doesn't look like it can be optimised to me. You've made it sargable by avoiding wrapping the column itself in any date/time functions.

Do you have an index on row_date?

0

精彩评论

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