Thursday, July 16, 2020

select max from large table performance

Select max(ddate) from transactions where code='KSH';

Change to 

Select ddate from ( select ddate from transactions where code='KSH' order by ddate desc) where rownum=1;

**** If that code is not exist in table then first query takes very much time but second one comes faster.

Also can change into subquery

No comments:

Post a Comment

Followers