| From: | Yan Chunlu <springrider(at)gmail(dot)com> |
|---|---|
| To: | pgsql-performance(at)postgresql(dot)org |
| Subject: | how could select id=xx so slow? |
| Date: | 2012-07-06 06:17:23 |
| Message-ID: | CAOA66tEJLDOt4JpJ0RwOEsgizfQPWkCHd+SgT7kbiHix_io18A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
I have grabbed one day slow query log and analyzed it by pgfouine, to my
surprise, the slowest query is just a simple select statement:
*select diggcontent_data_message.thing_id, diggcontent_data_message.KEY,
diggcontent_data_message.value, diggcontent_data_message.kind FROM
diggcontent_data_message WHERE diggcontent_data_message.thing_id = 3570882;*
where thing_id is the primary key, guess how long it takes?
754.61 seconds!!
I tried explain analyze it and below is the result, which is very fast:
*
*
*
explain analyze select diggcontent_data_message.thing_id,
diggcontent_data_message.KEY, diggcontent_data_message.value,
diggcontent_data_message.kind FROM diggcontent_data_message WHERE
diggcontent_data_message.thing_id = 3570882;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using idx_thing_id_diggcontent_data_message on
diggcontent_data_message (cost=0.00..15.34 rows=32 width=51) (actual
time=0.080..0.096 rows=8 loops=1)
Index Cond: (thing_id = 3570882)
Total runtime: 0.115 ms
(3 rows)
*
so I wonder could this simple select is innocent and affected badly by
other queries? how could I find those queries that really slow down the
database?
thanks!
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2012-07-06 06:20:29 | Re: select operations that generate disk writes |
| Previous Message | CSS | 2012-07-06 06:10:36 | select operations that generate disk writes |