pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wambacher@posteo.de
To: pgsql-general@lists.postgresql.org
Subject: Re: update table with suppress_redundant_updates_trigger()
Date: Tue, 26 Feb 2019 10:10:30 +0100
Message-ID: <45ae5825-0f5c-c9d1-412b-1e4d89149ad3@posteo.de> (raw)
In-Reply-To: <fa1d484b-2416-041f-9de3-1ff520307f96@posteo.de>
References: <fa1d484b-2416-041f-9de3-1ff520307f96@posteo.de>

Problem "solved".

"found" will be true of false depending on the trigger action.

update done -> found = true, update not done -> found=false.

But: The trigger sometimes allows updates where no data has been
changed! That is another problem to be solved :(

Regards

walter

Am 25.02.19 um 19:42 schrieb wambacher@posteo.de:
>
> 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-boun...;
> 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;
-- 
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-boun...;
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;


view thread (3+ messages)

Message-ID: <45ae5825-0f5c-c9d1-412b-1e4d89149ad3@posteo.de>
Permalink:  ../45ae5825-0f5c-c9d1-412b-1e4d89149ad3@posteo.de/
Also on:    postgresql.org/message-id/45ae5825-0f5c-c9d1-412b-1e4d89149ad3@posteo.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: wambacher@posteo.de
  Subject: Re: update table with suppress_redundant_updates_trigger()
  In-Reply-To: <45ae5825-0f5c-c9d1-412b-1e4d89149ad3@posteo.de>
  References: <fa1d484b-2416-041f-9de3-1ff520307f96@posteo.de> <45ae5825-0f5c-c9d1-412b-1e4d89149ad3@posteo.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox