Re: getting the ranks out of items with SHARED - Mailing list pgsql-general

From Tom Lane
Subject Re: getting the ranks out of items with SHARED
Date
Msg-id 26967.1121205783@sss.pgh.pa.us
Whole thread Raw
In response to getting the ranks out of items with SHARED  (Janning Vygen <vygen@gmx.de>)
Responses postgresql SSL off
Re: getting the ranks out of items with SHARED
List pgsql-general
Janning Vygen <vygen@gmx.de> writes:
> I have a guess, what happens here: The order of the subselect statement is
> dropped by the optimizer because the optimizer doesn't see the "side-effect"
> of the ranking function.

That guess is wrong.

I think the problem is that you are trying to update multiple rows in
the same statement, which would require a "reset ranking" between each
row, which this approach doesn't provide for.

The whole thing looks mighty fragile in other ways; anything involving a
single global variable isn't going to work nicely in very many cases.
Consider casting your solution as an aggregate instead...

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.2 -> 7.4: horrible performance hit!
Next
From: Alvaro Herrera
Date:
Subject: Re: Converting MySQL tinyint to PostgreSQL