Re: problems maintaining boolean columns in a large table

From: Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com>
To: Ben Campbell <ben(at)scumways(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problems maintaining boolean columns in a large table
Date: 2010-02-11 14:20:06
Message-ID: 92869e661002110620l2683933bk43843ff8aa8a5cd3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/2/10 Ben Campbell <ben(at)scumways(dot)com>

> I settled on:
>
> CREATE TABLE needs_indexing (
> article_id integer REFERENCES article(id) PRIMARY KEY
> );
>
> The primary key-ness enforces uniqueness, and any time I want to add an
> article to the queue I just make sure I do a DELETE before the INSERT. Bound
> to be more efficient ways to do it, but it works.
>
> better use

INSERT INTO needs_indexing (article_id)
SELECT NEW.id
WHERE NOT EXISTS ( SELECT 42 FROM needs_indexing WHERE article_id = NEW.id
);

--
Filip Rembiałkowski
JID,mailto:filip(dot)rembialkowski(at)gmail(dot)com
http://filip.rembialkowski.net/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Timo Klecker 2010-02-11 14:23:25 Re: problems maintaining boolean columns in a large table
Previous Message Filip Rembiałkowski 2010-02-11 14:12:51 Re: error migrating database from 8.4 to 8.3