Search Postgresql Archives

Re: Singleton table (was Re: How to don't update sequence on rollback of a transaction)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/03/2012 12:07 PM, Chris Angelico wrote:
On Fri, Aug 3, 2012 at 10:00 AM, Craig Ringer <ringerc@xxxxxxxxxxxxx> wrote:
-- PostgreSQL specific hack you can use to make
-- really sure only one row ever exists
CREATE UNIQUE INDEX there_can_be_only_one
ON invoice_number( (1) );
This will guarantee that there's only one row. Does Postgres then
optimize anything based on this? I have a couple of cases where I'm
using a table to store global configuration, and selecting/updating
that table without a WHERE clause to manipulate it. Can PostgreSQL
notice the "highlander" status of the table and know not to go looking
for more?

As far as I know, no. If anything it could slow things down a tad. I just like to be really sure it's a single row table.

An `ON INSERT OR DELETE` trigger that throws is probably a more sensible option, really.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux