http://qs1969.pair.com?node_id=350261


in reply to What's an Efficient Way to Retrieve a Rank from a MySQL Table?

If the rank of a student is relative to the population you cant determine the rank on the fly without looking at the population.

My idea would be to run a job periodically that would do that for you, compute the value and store it statically in a table.

Alternatively you could write an internal function that did that for you eg: select rank(student) from students.. and the rank function would be something you write yourself. not sure if MySQL supports custom functions in perl, (and i'm too lazy to look it up) but postgres sure does.. (not that i'm suggesting you switch RBDMS's) :-).