Re: primary key and unique index

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Thomas Poty <thomas(dot)poty(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: primary key and unique index
Date: 2018-03-23 08:10:40
Message-ID: CAKJS1f_1o25K7+ZavWfbPe=AM2TmFjFqGb2GWFLK0CBC7cdstA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 23 March 2018 at 20:55, Thomas Poty <thomas(dot)poty(at)gmail(dot)com> wrote:
> In MySQL a "show create table" gives me :
> ...
> PRIMARY KEY (`ID`,`CountryCode`,`LanguageCode`),
> UNIQUE KEY `unique_my table_4` (`ID`,`CountryCode`,`LanguageCode`),
> ...
>
> So, In PostgreSQL, does it make sense to create a primary key AND a unique
> index based on the same columns?
> Is PostgreSQL smart enough to use the unique index created for the primary
> key.

Doing this makes no sense in PostgreSQL. I'm struggling to imagine
why it would in MySQL.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alessandro Aste 2018-03-23 08:31:26 Re: Postgresql 10.3 , query never completes if LIMIT clause is specified and paralle processing is on
Previous Message Thomas Poty 2018-03-23 07:55:35 primary key and unique index