Re: Protect a table against concurrent data changes while allowing to vacuum it

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Protect a table against concurrent data changes while allowing to vacuum it
Date: 2016-06-22 17:51:50
Message-ID: 3da937d8-4e7f-4627-2a7d-e68ebfcdbd93@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/22/2016 3:07 AM, Vlad Arkhipov wrote:
>
> CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT);
>
> The constraint that the data must satisfy is `there is no more than 3
> records with the same name`.
>
> I am not in control of queries that modify the table, so advisory
> locks can hardly be of help to me.

select name from t group by name having count(id)>3

will return all names with more than 3 records in a single query... now
the question is, what do you want to do with this information ?

--
john r pierce, recycling bits in santa cruz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Vanasco 2016-06-22 18:23:55 Re: optimizing a query
Previous Message Sameer Kumar 2016-06-22 17:06:03 What Causes Access Exclusive Lock?