MySQL Forums
Forum List  »  General

Re: Record Position in Ordered Selection
Posted by: Peter Brawley
Date: June 08, 2009 02:21AM

Alan,

With a big table, self-joins are slow. They don't scale. As suggested by another poster, it can be faster to create creating a temp table ...

DROP TABLE IF EXISTS tmp;
SET @i=0;
CREATE TEMPORARY TABLE tmp
SELECT idcol,valuecol,@i:=@i+1 AS rank
ORDER BY valuecol DESC;

but handling ties will need another pass, which will again be slow.

PB
http://www.artfulsoftware.com

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.