Not wanting to be awkward or anything, but ...

Paul Makepeace wrote:

On Wed, Jan 29, 2003 at 12:10:38PM +0000, the hatter wrote:

On Wed, 29 Jan 2003, Paul Makepeace wrote:


So there are a bunch of things "order by rank". I'd like to implement a
move up/down in SQL. So say the target was id=20 moving up, I'd like its
rank to become 1, and id=10's rank to become 2.

$query = "UPDATE fw SET rank=rank+(-2*(rank-($position+0.5))) WHERE ";
$query .= "(rank=$position OR rank=$position+1)"

... I have seen cases (under Informix and MySQL) where the use of an OR clause causes a sequential scan of the entire table. With a largish table under production load, the results are... interesting.
You might want to check that Postgres doesn't do that (using whatever its EXPLAIN functionality is).

Cheers

Ti'



Reply via email to