From: | Dawid Kuroczko <qnex42(at)gmail(dot)com> |
---|---|
To: | Sebastian Böck <sebastianboeck(at)freenet(dot)de> |
Cc: | Jaime Casanova <systemguards(at)gmail(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Update on tables when the row doesn't change |
Date: | 2005-05-25 07:45:54 |
Message-ID: | 758d5e7f05052500452ca4fa19@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 5/24/05, Sebastian Böck <sebastianboeck(at)freenet(dot)de> 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 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 = OLD.id;
> UPDATE join1 SET text1 = NEW.text1 WHERE id = OLD.id;
> UPDATE join2 SET text2 = NEW.text2 WHERE id = OLD.id;
> UPDATE join3 SET text3 = NEW.text3 WHERE id = OLD.id;
> RETURN;
> END;
> $$ LANGUAGE plpgsql;
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. :)
Regards,
Dawid
From | Date | Subject | |
---|---|---|---|
Next Message | Dweck Nir | 2005-05-25 08:08:54 | postmaster fails to start |
Previous Message | Richard Huxton | 2005-05-25 06:52:13 | Re: Update on tables when the row doesn't change |