Oracle Logbook

May 2, 2011


Filed under: Uncategorized — Helio Dias @ 8:00 pm

It´s a wonderful simple idea,

select * from (select cpf,valor from CM.TAB_DIRF order by 2 desc) where rownum=1

On the above query one might think that the ordering cost will become prohibitive

IT ISN`T thanks to COUNT STOPKEY Oracle is pretty clever to pick up just one value (as the outside filter is 1)

Then Oracle just check if the new values is higher or not than the previous one.

The bottom line is , there is NO ordering at all.

Blog at