Thread: Slow insert

Slow insert

From
Christopher Kings-Lynne
Date:
Hi guys,

Why would an INSERT ever be really slow?  This is what I see a lot of in
our site logs:

Dec  5 15:57:48 marshall postgres[19599]: [3-1] LOG:  duration:
13265.492 ms  statement: INSERT INTO users_sessions (sid, cobrand_id,
uid) VALUES ('145982ac39e1d09fec99cc8a606155e7', '1', '0')

13 seconds to insert a single row!

It seems to happen at random times during the day.  That sessions table
is heavily updated and inserted, and has pg_autovacuum running vacuum
analyze and analyze on it every few minutes I think.

We don't run any exclusive lock stuff on it.

So what lock or concurrency issue could cause a single-row insert to
take 13 seconds?  Could vacuum analyze be doing it?

Thanks,

Chris

Re: Slow insert

From
"Steinar H. Gunderson"
Date:
On Wed, Dec 08, 2004 at 10:42:19AM +0800, Christopher Kings-Lynne wrote:
> Why would an INSERT ever be really slow?  This is what I see a lot of in
> our site logs:
>
> Dec  5 15:57:48 marshall postgres[19599]: [3-1] LOG:  duration:
> 13265.492 ms  statement: INSERT INTO users_sessions (sid, cobrand_id,
> uid) VALUES ('145982ac39e1d09fec99cc8a606155e7', '1', '0')
>
> 13 seconds to insert a single row!

Do you have a foreign key or other check which could be really slow?

/* Steinar */
--
Homepage: http://www.sesse.net/