Re: "RETURNING PRIMARY KEY" syntax extension - Mailing list pgsql-hackers

From David G Johnston
Subject Re: "RETURNING PRIMARY KEY" syntax extension
Date
Msg-id 1402292822318-5806463.post@n5.nabble.com
Whole thread Raw
In response to "RETURNING PRIMARY KEY" syntax extension  (Ian Barwick <ian@2ndquadrant.com>)
Responses Re: "RETURNING PRIMARY KEY" syntax extension  (David G Johnston <david.g.johnston@gmail.com>)
Re: "RETURNING PRIMARY KEY" syntax extension  (Ian Barwick <ian@2ndquadrant.com>)
Re: "RETURNING PRIMARY KEY" syntax extension  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Re: "RETURNING PRIMARY KEY" syntax extension  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-hackers
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.



pgsql-hackers by date:

Previous
From: Ian Barwick
Date:
Subject: "RETURNING PRIMARY KEY" syntax extension
Next
From: David G Johnston
Date:
Subject: Re: "RETURNING PRIMARY KEY" syntax extension