Re: Query plan when using currval

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Query plan when using currval
Date: 2018-05-09 22:22:04
Message-ID: CAKJS1f-kuOuDT6XnUqPt84TMb4SWXSk8qvSOuaeG3tkyaV8Cvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 9 May 2018 at 18:24, Steve Baldwin <steve(dot)baldwin(at)gmail(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Steve Baldwin 2018-05-09 22:32:01 Re: Query plan when using currval
Previous Message Tom Lane 2018-05-09 14:17:52 Re: Query plan when using currval