update table with suppress_redundant_updates_trigger()

From: wambacher(at)posteo(dot)de
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: update table with suppress_redundant_updates_trigger()
Date: 2019-02-25 18:42:55
Message-ID: fa1d484b-2416-041f-9de3-1ff520307f96@posteo.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

i'm doing a lot of updates in my database, but most of them are not
necessary at all (sorry, just detected it)

Therefore i installed a trigger to minimize real updates.

create trigger suppress_redundant_updates_boundaries
   before update on boundaries
   for each row execute procedure suppress_redundant_updates_trigger();

Is there a way to get the count of the real table updates?

Using pl/pgsql i'm updating boundaries  with

                  update boundaries
                     set id             = bT2.id,
                         country        = bT2.country,
                         type           = 'admin',   
                         value          = bT2.value,
...
                        ,qm             = bT2.qm
                        ,lwqm           =
st_area(geography(coalesce(xlandarea,rT.way)))
                   where id = bT2.id;

                   if (found) then
                      if (debug > 0) then raise notice 'real db update
of % done 2', bT2.id; end if;
                      updatedDB := updatedDB + 1;
                   end if;

i get a "wrong" result, because "found" is always true, even when the
records are identical (hope so) and an update should be suppressed by
the trigger.

Question: will "found" be set when update has been blocked by the
trigger - or does that not matter?

if "found" is always true: what else can i do?

regards

walter

--
My projects:

Admin Boundaries of the World <https://wambachers-osm.website/boundaries>
Missing Boundaries
<https://wambachers-osm.website/index.php/projekte/internationale-administrative-grenzen/missing-boundaries>
Emergency Map <https://wambachers-osm.website/emergency>
Postal Code Map (Germany only) <https://wambachers-osm.website/plz>
Fools (QA for zipcodes in Germany) <https://wambachers-osm.website/fools>
Postcode Boundaries of Germany <https://wambachers-osm.website/pcoundaries>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Filip Rembiałkowski 2019-02-25 19:06:42 9.0 standby - could not open file global/XXXXX
Previous Message Daniel Fink (PDF) 2019-02-25 18:30:42 RE: bdr replication breaks down