From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Gavin Wahl <gwahl(at)fusionbox(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE) |
Date: | 2017-04-12 23:04:47 |
Message-ID: | CAKFQuwZKPAHdKxpBM-9Qy+AFd8Vvr0tNeB5VXq5FNp-+7J+n3Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Apr 12, 2017 at 3:56 PM, Gavin Wahl <gwahl(at)fusionbox(dot)com> wrote:
> > Given this limited example I'd probably choose to model notifications as
> an
> > array on the user table. Then just "UPDATE user SET notifications =
> > array['a','b']::text WHERE user_id = 1;
>
> I'm hesitant to ditch the first normal form just to get around this.
> Anyway,
> there's actually extra data in the table that makes it hard to use an
> array:
>
> CREATE TABLE notifications (
> user_id INT,
> type CHAR(1),
> threshold INT,
> some_options BOOLEAN,
> PRIMARY KEY (user_id, type)
> );
>
A custom composite type would solve that part of the problem.
You're going to have to pick you poison here. No serializable, no locking,
and no atomic data type. I don't have any other reasonable ideas that
aren't any worse than any one of those three. You would need to introduce
some kind of "notification set id" and make (user_id,
active_notification_set_id) the linking multi-column key.
Or wait and see if anyone more clever than I has some ideas.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2017-04-12 23:10:26 | Re: Error During PostGIS Build From Source on Linux |
Previous Message | Gavin Wahl | 2017-04-12 22:56:46 | Re: Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE) |