Search Postgresql Archives

Re: Column order in multi column primary key

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

 



"Craig Boucher" <craig@xxxxxxxxxx> writes:
> I should have pointed out in my last response that I was wondering if the performance of the pk index on work_session would be better if my primary key was (customer_id, work_session_id) or if (work_session_id,  customer_id) will be fine.  Customer_id will be repeated quite a bit in the table but work_session_id should be unique across the whole table.

You almost certainly want the more-unique column first, so far as the
performance of the index itself goes.  See
https://www.postgresql.org/docs/9.5/static/indexes-multicolumn.html

Having said that, I'm pretty skeptical of the notion of redefining what
your PK is on performance grounds.  With this definition, you'd allow
two entries with the same work_session_id, if they chanced to have
different customer_ids.  Is that really OK?

			regards, tom lane


-- 
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