Re: Message queue table..

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Message queue table..
Дата
Msg-id 4808E600.3060108@postnewspapers.com.au
обсуждение исходный текст
Ответ на Message queue table..  (Jesper Krogh <jesper@krogh.cc>)
Ответы Re: Message queue table..  (Jesper Krogh <jesper@krogh.cc>)
Список pgsql-performance
Jesper Krogh wrote:
>
> Hi.
>
> 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).
>
> Can anyone digest further optimizations out of this output? (All records
> have funcid=4)

You mean all records of interest, right, not all records in the table?

What indexes do you have in place? What's the schema? Can you post a "\d
tablename" from psql?

> # explain analyze SELECT job.jobid, job.funcid, job.arg, job.uniqkey,
> job.insert_time, job.run_after, job.grabbed_until, job.priority,
> job.coalesce FROM workqueue.job  WHERE (job.funcid = 4) AND
> (job.run_after <= 1208442668) AND (job.grabbed_until <= 1208442668) AND
> (job.coalesce = 'Efam') ORDER BY funcid, priority ASC LIMIT 1
> ;
>
>    QUERY PLAN
>
--------------------------------------------------------------------------------------------------------------------------------------------------------------

>
>  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
> (5 rows)

Without seeing the schema and index definitions ... maybe you'd benefit
from a multiple column index. I'd experiment with an index on
(funcid,priority) first.

--
Craig Ringer

В списке pgsql-performance по дате отправления:

Предыдущее
От: "Jeffrey Baker"
Дата:
Сообщение: Re: 3-days-long vacuum of 20GB table
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: 3-days-long vacuum of 20GB table