Re: problems maintaining boolean columns in a large table

From: Ben Campbell <ben(at)scumways(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: problems maintaining boolean columns in a large table
Date: 2010-02-10 14:49:23
Message-ID: 4B72C773.9060705@scumways.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Huxton wrote:
> On 09/02/10 11:25, Ben Campbell wrote:
[I was talking about moving a "needs_indexing" flag out of a big table
into it's own table]
>> But my gut feeling is that the flag would be better off in it's own
>> table anyway, eg:
>>
>> CREATE TABLE needs_indexing (
>> article_id integer references article(id)
>> );

> That sounds sensible to me

Cool - glad to know I'm not suggesting something totally insane! I never
can quite tell when I'm doing database stuff :-)

> Oh - you might want to consider how/whether to handle multiple entries
> for the same article in your queue.

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.

Thanks,
Ben.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2010-02-10 15:09:26 Re: Best way to handle multi-billion row read-only table?
Previous Message Asher 2010-02-10 14:32:48 Re: Best way to handle multi-billion row read-only table?