http://www.perlmonks.org?node_id=309301


in reply to Re: Problem with database under Win32
in thread Problem with database under Win32

Using SELECT TOP 1 From ..... ORDER BY ID DESC may be faster than trying a "Max".

I am not a SQL weenie though - you may want to check with your DBA as to why the subquery seems "slower".

  • Comment on Re: Re: Problem with database under Win32

Replies are listed 'Best First'.
Re: Re: Re: Problem with database under Win32
by l3nz (Friar) on Nov 23, 2003 at 19:34 UTC
    I am not sure - if you MAX() an index, you usually get top performance with no disk access at all; in any other case you need a table scan to know all the values, so you can max() them. My actual query is not any way similar to the one I am presenting here (it's a five-page belemoth, just in the case you wonder, even with all repeated subqueries extracted!)