Re: Query plan when using currval - Mailing list pgsql-novice

From David Rowley
Subject Re: Query plan when using currval
Date
Msg-id CAKJS1f-kuOuDT6XnUqPt84TMb4SWXSk8qvSOuaeG3tkyaV8Cvw@mail.gmail.com
Whole thread Raw
In response to Query plan when using currval  (Steve Baldwin <steve.baldwin@gmail.com>)
Responses Re: Query plan when using currval  (Steve Baldwin <steve.baldwin@gmail.com>)
List pgsql-novice
On 9 May 2018 at 18:24, Steve Baldwin <steve.baldwin@gmail.com> wrote:
> bcaas=> explain analyze select id from log_statement where id = (select currval('log_statement_id_seq'));

I know Tom has answered your question, but you may be interested in
INSERT RETURNING as this will save you from having to do this to
lookup the ID of the last inserted sequence value.

https://www.postgresql.org/docs/10/static/sql-insert.html

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


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Query plan when using currval
Next
From: Steve Baldwin
Date:
Subject: Re: Query plan when using currval