Re: maintaining a reference to a fetched row - Mailing list pgsql-performance

From Jeff Janes
Subject Re: maintaining a reference to a fetched row
Date
Msg-id f67928030911040847j434be6b0w59cf4a6218829ec3@mail.gmail.com
Whole thread Raw
In response to maintaining a reference to a fetched row  (Brian Karlak <zenkat@metaweb.com>)
Responses Re: maintaining a reference to a fetched row  (Brian Karlak <zenkat@metaweb.com>)
List pgsql-performance
On Tue, Nov 3, 2009 at 12:30 PM, Brian Karlak <zenkat@metaweb.com> wrote:
> Hello All --
>
> I have a simple queuing application written on top of postgres which I'm
> trying to squeeze some more performance out of.
>
> The setup is relatively simple: there is a central queue table in postgres.
>  Worker daemons do a bounded, ordered, limited SELECT to grab a row, which
> they lock by setting a value in the queue.status column.

So you do a select, and then an update?

> When the task is
> complete, results are written back to the row.  The system is designed to
> allow multiple concurrent daemons to access a queue.  At any one time, we
> expect 1-5M active items on the queue.
>
> Now this design is never going to win any performance awards against a true
> queuing system like Active/Rabbit/Zero MQ, but it's tolerably fast for our
> applications.  Fetch/mark times are about 1ms, independent of the number of
> items on the queue.  This is acceptable considering that our tasks take
> ~50ms to run.
>
> However, the writing of results back to the row takes ~5ms, which is slower
> than I'd like.

It seems you have an select, and update, and another update.  Where in
this process do you commit?  Are you using fsync=off or
synchronous_commit=off?

> It seems that this is because I need to to do an index scan
> on the queue table to find the row I just fetched.

Why would the index scan take 1 ms two of the times it is done but 5ms
the third time?  Isn't it the same index scan each time?  Or does the
change in queue.status change the plan?

Cheers,

Jeff

pgsql-performance by date:

Previous
From: Jeff Janes
Date:
Subject: Re: High Frequency Inserts to Postgres Database vs Writing to a File
Next
From: Anj Adu
Date:
Subject: Re: High Frequency Inserts to Postgres Database vs Writing to a File