Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Martijn van Oosterhout
On Wed, May 25, 2005 at 08:41:23AM -0700, Tim Vadnais wrote: > Hi All, > > Can someone please address this aspect of Sebastian's email? I, too, am > interested in the response. > > >> Why does Postgres perform an update on the table even > >> if no data changes? > >> Can I circumvent this behav

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Scott Marlowe
On Wed, 2005-05-25 at 10:41, Tim Vadnais wrote: > >> Why does Postgres perform an update on the table even > >> if no data changes? > >> Can I circumvent this behaviour of Postgres? > >> > Hi All, > > Can someone please address this aspect of Sebastian's email? I, too, am > interested in the re

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Tim Vadnais
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sebastian Böck Sent: Tuesday, May 24, 2005 8:06 AM To: pgsql-general@postgresql.org Subject: [GENERAL] Update on tables when the row doesn't change Hi all, Maybe it's a very silly question, but why does Postgres perform an up

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Sebastian Böck
Ragnar Hafstað wrote: On Wed, 2005-05-25 at 13:09 +0200, Sebastian Böck wrote: Dawid Kuroczko wrote: Be wary of the NULL values though. :) Either don't use them, add something like 'AND (text1 <> NEW.text1 OR text1 IS NULL OR NEW.text1 IS NULL)' or something more complicated. :) Thanks fo

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Ragnar Hafstað
On Wed, 2005-05-25 at 13:09 +0200, Sebastian Böck wrote: > Dawid Kuroczko wrote: > > > > > Be wary of the NULL values though. :) Either don't use them, add > > something like 'AND (text1 <> NEW.text1 OR text1 IS NULL OR NEW.text1 > > IS NULL)' or something more complicated. :) > > Thanks for th

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Sebastian Böck
Dawid Kuroczko wrote: Control question, I didn't check it, but would it be enough to change from: UPDATE join1 SET text1 = NEW.text1 WHERE id = OLD.id; to: UPDATE join1 SET text1 = NEW.text1 WHERE id = OLD.id AND text1 <> NEW.text1? ... I may be wrong. :) Yes, thats more elegant then my

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Dawid Kuroczko
On 5/25/05, Sebastian Böck <[EMAIL PROTECTED]> wrote: > >>CREATE OR REPLACE FUNCTION upd (view_test) RETURNS VOID AS $$ > >>DECLARE > >>NEW ALIAS FOR $1; > >>BEGIN > >>RAISE NOTICE 'UPDATE'; > >>UPDATE test SET test = NEW.test WHERE id

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Sebastian Böck
Martijn van Oosterhout wrote: Well, I havn't run the rule so I don't know exactly whether it is relevent, but simply put, RULEs are like *macro substitution*. In macros, if you specify an expression (like a view) as an argument, it is placed as a whole each place the argument is used. Yes I und

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Martijn van Oosterhout
Well, I havn't run the rule so I don't know exactly whether it is relevent, but simply put, RULEs are like *macro substitution*. In macros, if you specify an expression (like a view) as an argument, it is placed as a whole each place the argument is used. UPDATEs for different tables cannot be mer

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Sebastian Böck
Dawid Kuroczko wrote: On 5/24/05, Sebastian Böck <[EMAIL PROTECTED]> wrote: /* 3rd way of separating updates con: unnecessary updates on tables pro: view gets evaluated only 1 time Not adressing the problem of unnecessary updates, but the view gets only evaluated one time. */ CREATE

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Dawid Kuroczko
On 5/24/05, Sebastian Böck <[EMAIL PROTECTED]> wrote: > /* 3rd way of separating updates >con: unnecessary updates on tables >pro: view gets evaluated only 1 time > >Not adressing the problem of unnecessary updates, but the view >gets only evaluated one time. > > */ > > CREATE OR

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-25 Thread Richard Huxton
Tom Lane wrote: =?ISO-8859-1?Q?Sebastian_B=F6ck?= <[EMAIL PROTECTED]> writes: Why does Postgres perform updates to tables, even if the row doesn't change at all? Because testing for this would almost surely be a net loss for the vast majority of applications. Checking to see if the new row

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Tom Lane
=?ISO-8859-1?Q?Sebastian_B=F6ck?= <[EMAIL PROTECTED]> writes: > Why does Postgres perform updates to tables, even if the row doesn't > change at all? Because testing for this would almost surely be a net loss for the vast majority of applications. Checking to see if the new row value exactly equ

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Sebastian Böck
Sorry, missed the SQL to test. Sebastian /* tables */ CREATE TABLE test ( id INTEGER PRIMARY KEY, test TEXT NOT NULL ); CREATE TABLE join1 ( id INTEGER PRIMARY KEY, text1 TEXT NOT NULL ); CREATE TABLE join2 ( id INTEGER PRIMARY KEY, text2 TEXT NO

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Sebastian Böck
Jaime Casanova wrote: On 5/24/05, Sebastian Böck <[EMAIL PROTECTED]> wrote: Martijn van Oosterhout wrote: I'm sure I'm not the only one, but, what are you talking about? RULEs are not really obvious so it would help if you could post an example of what you mean... I attach some sample SQL (

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Jaime Casanova
On 5/24/05, Sebastian Böck <[EMAIL PROTECTED]> wrote: > Martijn van Oosterhout wrote: > > I'm sure I'm not the only one, but, what are you talking about? RULEs > > are not really obvious so it would help if you could post an example of > > what you mean... > > > > Have a nice day, > > Hi, I'm not

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Sebastian Böck
Martijn van Oosterhout wrote: I'm sure I'm not the only one, but, what are you talking about? RULEs are not really obvious so it would help if you could post an example of what you mean... Have a nice day, Hi, I'm not really talking about rules. I'm talking about updates on *real* tables, and

Re: [GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Martijn van Oosterhout
I'm sure I'm not the only one, but, what are you talking about? RULEs are not really obvious so it would help if you could post an example of what you mean... Have a nice day, On Tue, May 24, 2005 at 05:05:34PM +0200, Sebastian Böck wrote: > Hi all, > > maybe it's a very silly question, but why

[GENERAL] Update on tables when the row doesn't change

2005-05-24 Thread Sebastian Böck
Hi all, maybe it's a very silly question, but why does Postgres perform an update on the table even if no data changes? I recognized this recently doing a rewrite of my rules because they took to long. I had many conditional rules I collapsed to one unconditional rule, so that the views get