Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/24/05, Sebastian Böck <sebastianboeck@xxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux