From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Andrus *EXTERN*" <kobruleht2(at)hot(dot)ee>, "Christophe Pettus" <xof(at)thebuild(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to use read uncommitted transaction level and set update order |
Date: | 2009-12-20 16:16:56 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C203A8991E@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You are confusing a few things, and you don't want to hear the
explanations because they are inconvenient.
Andrus wrote:
> 1. In my case b expression needs values from previous rows updated in this
> same command before:
You are confusing "to the left of" and "before".
If you want behaviour that deviates from the SQL standard, you will
usually meet fierce resistance from PostgreSQL.
> I understood from replies that
>
> set transaction isolation level read uncommitted;
>
> in PostgreSql is broken: it sets silently committed isolation level.
You should read this:
http://www.postgresql.org/docs/8.4/static/transaction-iso.html
I agree that the behaviour may be surprising, but "broken" is polemic.
This is not always a good comparison when standard behaviour is
concerned, but Oracle does it the same way.
> 2. In my planned UPDATE statement instead of 4 there is an expression
> containing one big CASE WHEN expression with many WHEN .. THEN clauses.
> This command takes several hundreds of lines.
> Your solution requires repeating this expression two times and thus makes
> sql difficult to read.
... plus the expression would be evaluated twice. But you cannot hold that against
the person who gave you the advice, because you hid that fact.
Why don't you let your imagination play a little:
1) You could use a subquery like
UPDATE foo SET col = myex
FROM (SELECT foo_id, <your 100 lines here> AS myex FROM whatever ...) AS bar
WHERE foo.foo_id = bar.foo_id;
2) You could define a stable SQL function for your 100 line subquery which
should be evaluated only once in the UPDAT query.
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | OpenLink Support | 2009-12-20 18:27:37 | Re: Unix ODBC on SPARC 64 bits |
Previous Message | Larry Anderson | 2009-12-20 15:56:47 | Re: Transaction started test |