From: James DeMichele <James.DeMichele@redfin.com>
To: pgsql-performance@postgresql.org
Subject: Simple select, but takes long time
Date: Fri, 11 Jan 2008 17:33:54 -0800
Message-ID: <082D8A131DF72A4D88C908A1AD3DEB2201AF140E@mail-1.rf.lan> (raw)
Hi,
I am having a really hard time trying to figure out why my simple
count(*) query is taking so long. I have a table with 1,296,070 rows in
it. There are 2 different types of information that each row has that I
care about:
status : character(1)
source_id : bigint
Then, I have the following index on the table:
"this_index" (status, source_id, <another_column>)
Now when I do the following select, it takes a really long time:
stingray_4_4_d=# explain analyze select count(*) from listings where
insert_status = '1' and data_source_id = 52;
QUERY PLAN
------------------------------------------------------------------------
------------------------------------------------------------------------
---
Aggregate (cost=15222.83..15222.84 rows=1 width=0) (actual
time=87050.129..87050.130 rows=1 loops=1)
-> Index Scan using listing_status_idx on listings
(cost=0.00..15211.20 rows=4649 width=0) (actual time=31.118..87031.776
rows=17209 loops=1)
Index Cond: ((insert_status = '1'::bpchar) AND (data_source_id
= 52))
Total runtime: 87050.213 ms
(4 rows)
I actually have the same exact data over on a Mysql box, with the same
exact index, and that runs in 0.10 seconds.
Clearly something is wrong. Here are a couple of the parameters I have
set on my Postgres box:
stingray_4_4_d=# show shared_buffers;
shared_buffers
----------------
1900MB
(1 row)
stingray_4_4_d=# show max_fsm_pages;
max_fsm_pages
---------------
5000000
(1 row)
Any help would be much appreciated. This is really frustrating. Thanks.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: James.DeMichele@redfin.com
Subject: Re: Simple select, but takes long time
In-Reply-To: <082D8A131DF72A4D88C908A1AD3DEB2201AF140E@mail-1.rf.lan>
References: <082D8A131DF72A4D88C908A1AD3DEB2201AF140E@mail-1.rf.lan>
* 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