pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jesper Krogh <jesper@krogh.cc>
Cc: pgsql-performance@postgresql.org
Subject: Re: Message queue table..
Date: Fri, 18 Apr 2008 15:27:02 -0400
Message-ID: <7590.1208546822@sss.pgh.pa.us> (raw)
In-Reply-To: <4808DF33.8000008@krogh.cc>
References: <4808DF33.8000008@krogh.cc>

Jesper Krogh <jesper@krogh.cc> writes:
> I have this "message queue" table.. currently with 8m+ records. Picking 
> the top priority messages seem to take quite long.. it is just a matter 
> of searching the index.. (just as explain analyze tells me it does).

>   Limit  (cost=0.00..0.09 rows=1 width=106) (actual 
> time=245.273..245.274 rows=1 loops=1)
>     ->  Index Scan using workqueue_job_funcid_priority_idx on job 
> (cost=0.00..695291.80 rows=8049405 width=106) (actual 
> time=245.268..245.268 rows=1 loops=1)
>           Index Cond: (funcid = 4)
>           Filter: ((run_after <= 1208442668) AND (grabbed_until <= 
> 1208442668) AND ("coalesce" = 'Efam'::text))
>   Total runtime: 245.330 ms

Well, what that's doing in English is: scan all the rows with funcid =
4, in priority order, until we hit the first one satisfying the filter
conditions.  Apparently there are a lot of low-priority rows that have
funcid = 4 but not the other conditions.

If it's the "coalesce" condition that's the problem, an index on
(funcid, coalesce, priority) --- or (coalesce, funcid, priority) ---
would probably help.  I'm not sure there's a simple fix if it's
the other conditions that are really selective.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <7590.1208546822@sss.pgh.pa.us>
Permalink:  ../7590.1208546822@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7590.1208546822@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, jesper@krogh.cc
  Subject: Re: Message queue table..
  In-Reply-To: <7590.1208546822@sss.pgh.pa.us>

* 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