Re: [GENERAL] Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE)

2017-04-12 Thread David G. Johnston
On Wed, Apr 12, 2017 at 3:56 PM, Gavin Wahl 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

Re: [GENERAL] Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE)

2017-04-12 Thread Gavin Wahl
> 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

Re: [GENERAL] Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE)

2017-04-12 Thread David G. Johnston
On Wed, Apr 12, 2017 at 3:32 PM, Gavin Wahl wrote: > I have a table that stores user notifications: > > CREATE TABLE notifications ( > user_id INT, > type CHAR(1), > PRIMARY KEY (user_id, type) > ); > ​[...]​ > > > Is there any way to do this correctly without

[GENERAL] Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE)

2017-04-12 Thread Gavin Wahl
I have a table that stores user notifications: CREATE TABLE notifications ( user_id INT, type CHAR(1), PRIMARY KEY (user_id, type) ); When a user edits their notifications, I need to atomically replace the old set with the new set. My first instinct is to do this: BEGIN; DELETE FROM