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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Analyse without locking?


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: Richard Neill <rn214(at)cam(dot)ac(dot)uk>
  • Cc: PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
  • Subject: Re: Analyse without locking?
  • Date: Thu, 26 Nov 2009 11:26:45 -0500
  • Message-id: <3165.1259252805@sss.pgh.pa.us> <text/plain>

Richard Neill <rn214(at)cam(dot)ac(dot)uk> writes:
> I'm wondering whether Vacuum/analyse (notably by the autovaccuum daemon) 
> is responsible for some deadlocks/dropouts I'm seeing.

> One particular table gets hit about 5 times a second (for single row 
> updates and inserts) + associated index changes. This is a very light 
> load for the hardware; we have 7 CPU cores idling, and very little disk 
> activity. The query normally runs in about 20 ms.

> However, the query must always respond within 200ms, or userspace gets 
> nasty errors.  [we're routing books on a sorter machine, and the book 
> misses its exit opportunity]. Although this is a low load, it's a bit 
> like a heartbeat.

> The question is, could the autovacuum daemon (running either in vacuum 
> or in analyse mode) be taking out locks on this table that sometimes 
> cause the query response time to go way up (exceeding 10 seconds)?

Hmm.  Autovacuum does sometimes take an exclusive lock.  It is supposed
to release it "on demand" but if I recall the details correctly, that
could involve a delay of about deadlock_timeout, or 1s by default.
It would be reasonable to reduce deadlock_timeout to 100ms to ensure
your external constraint is met.

Delays of up to 10s would not be explained by that though.  Do you have
usage spikes of other types?  I wonder in particular if you've got
checkpoints smoothed out enough.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group