Skip site navigation (1) Skip section navigation (2)

Re: Select from sequence in slow query log

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Rimmer <chrisr(at)we7(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Select from sequence in slow query log
Date: 2012-06-01 13:47:53
Message-ID: 23954.1338558473@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Chris Rimmer <chrisr(at)we7(dot)com> writes:
> While investigating some performance issues I have been looking at slow
> queries logged to the postgresql.log file.  A strange thing that I have
> seen is a series of apparently very slow queries that just select from a
> sequence. It is as if access to a sequence is blocked for many sessions and
> then released as I get log entries like this appearing:

> LOG:  duration: 23702.553 ms  execute <unnamed>: /* dynamic native SQL
> query */ select nextval ('my_sequence') as nextval
> LOG:  duration: 23673.068 ms  execute <unnamed>: /* dynamic native SQL
> query */ select nextval ('my_sequence') as nextval
> LOG:  duration: 23632.729 ms  execute <unnamed>: /* dynamic native SQL
> query */ select nextval ('my_sequence') as nextval
> ....(Many similar lines)....

That's pretty weird.  What else is being done to that sequence?  Is it
only the sequence ops that are slow, or does this happen at times when
everything else is slow too?  Can you create a reproducible test case?

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2012-06-01 15:15:09
Subject: Re: does the query planner consider work_mem?
Previous:From: Chris RimmerDate: 2012-06-01 13:13:21
Subject: Select from sequence in slow query log

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group