Posts Tagged ‘update’

Waiting for 8.4 - suppress_redundant_updates_trigger

2008-11-05 21:49:38 CET | 5 Comments | Tags: , , , ,

On 3rd of November Andrew Dunstan committed his patch which adds new function to PostgreSQL - suppress_redundant_updates_trigger().

This function is not for using in selects, but it can help you tremendously if your database access matches certain pattern.

- MORE -

Tips N’ Tricks - setting field based on order

2008-10-30 17:50:25 CET | 2 Comments | Tags: , , ,

Let’s imagine following situation:

create table test (id int4 primary key, priority int4);
insert into test (id)
select distinct (random() * 100000000)::int4 from generate_series(1,1000);

Table test will now contain some (up to 1000) records, with random ids.

Now, we want to update first 3 records (ordered by id) to have following values in priority:

  1. 10000
  2. 5000
  3. 1000

- MORE -