Re: "RETURNING PRIMARY KEY" syntax extension

From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: "RETURNING PRIMARY KEY" syntax extension
Date: 2014-06-09 07:06:30
Message-ID: 53955CF6.3090107@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09/06/14 17:47, David G Johnston wrote:
> Ian Barwick wrote
>> Hi,
>>
>> The JDBC API provides the getGeneratedKeys() method as a way of retrieving
>> primary key values without the need to explicitly specify the primary key
>> column(s). This is a widely-used feature, however the implementation has
>> significant
>> performance drawbacks.
>>
>> Currently this feature is implemented in the JDBC driver by appending
>> "RETURNING *" to the supplied statement. However this means all columns of
>> affected rows will be returned to the client, which causes significant
>> performance problems, particularly on wide tables. To mitigate this, it
>> would
>> be desirable to enable the JDBC driver to request only the primary key
>> value(s).
> Seems like a good idea.
>
>
>> ERROR: Relation does not have any primary key(s)
> "Relation does not have a primary key."
> or
> "Relation has no primary key." (preferred)
>
> By definition it cannot have more than one so it must have none.
>
> It could have multiple unique constraints but I do not believe they are
> considered if not tagged as primary.
>
> David J.
>
>
>
>
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/RETURNING-PRIMARY-KEY-syntax-extension-tp5806462p5806463.html
> Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
>
>
From memory all unique keys can be considered 'candidate primary keys',
but only one can be designated 'the PRIMARY KEY'.

I also like your preferred error message, and to the full extent of my
decidedly Non-Authority, I hereby authorise it! :-)

Cheers,
Gavin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message b8flowerfire 2014-06-09 08:06:24 why postgresql define NTUP_PER_BUCKET as 10, not other numbers smaller
Previous Message David Johnston 2014-06-09 07:04:44 Re: "RETURNING PRIMARY KEY" syntax extension