pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Karlsson <andreas@proxel.se>
To: Josh Berkus <josh@berkus.org>
To: Dinesh Chandra 12108 <Dinesh.Chandra@cyient.com>
To: pgsql-performance-owner@postgresql.org <pgsql-performance-owner@postgresql.org>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Auto generate number in Postgres-9.1.
Date: Mon, 20 Mar 2017 14:48:23 +0100
Message-ID: <84f4e415-02ef-b22b-8a3e-6d95b66b660b@proxel.se> (raw)
In-Reply-To: <97da050c-395c-7205-c5e9-95e7fdf13fde@berkus.org>
References: <ab77f3e1c16540a09002740e283529c5@cyient.com>
	<97da050c-395c-7205-c5e9-95e7fdf13fde@berkus.org>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

On 03/20/2017 02:43 PM, Josh Berkus wrote:
>> If I truncate the same table and then again insert rows should start
>> with 1 in “ID” column.
>
> That's not how it works, normally.  I'd suggest adding an ON TRUNCATE
> trigger to the table.

Actually that may not be necessary as long as you make sure to use the 
RESTART IDENTITY option when running TRUNCATE. I would argue that is a 
cleaner solution than using triggers, if you can get away with it.

https://www.postgresql.org/docs/9.6/static/sql-truncate.html

Andreas


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (6+ messages)  latest in thread

Message-ID: <84f4e415-02ef-b22b-8a3e-6d95b66b660b@proxel.se>
Permalink:  ../84f4e415-02ef-b22b-8a3e-6d95b66b660b@proxel.se/
Also on:    postgresql.org/message-id/84f4e415-02ef-b22b-8a3e-6d95b66b660b@proxel.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: andreas@proxel.se, josh@berkus.org, Dinesh.Chandra@cyient.com, pgsql-performance-owner@postgresql.org
  Subject: Re: Auto generate number in Postgres-9.1.
  In-Reply-To: <84f4e415-02ef-b22b-8a3e-6d95b66b660b@proxel.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox