Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 6B9D69FA4AE for ; Sun, 15 Oct 2006 19:27:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 34245-03 for ; Sun, 15 Oct 2006 22:27:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B15F89FA040 for ; Sun, 15 Oct 2006 19:27:19 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k9FMRI28002809; Sun, 15 Oct 2006 18:27:18 -0400 (EDT) To: "Carlo Stonebanks" cc: pgsql-performance@postgresql.org Subject: Re: Performance Optimization for Dummies 2 - the SQL In-reply-to: References: <1160153623.6181.13.camel@state.g2switchworks.com> Comments: In-reply-to "Carlo Stonebanks" message dated "Sun, 15 Oct 2006 17:46:13 -0400" Date: Sun, 15 Oct 2006 18:27:18 -0400 Message-ID: <2808.1160951238@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/282 X-Sequence-Number: 21411 "Carlo Stonebanks" writes: > Curiously, it's using index scans, and it really looks like a simple query > to me. I am completely baffled. The two tables in question have about 800K > rows each - not exactly an incredible number. The EXPLAIN is simple, but the > performance is dreadful. All the other queries run much faster than this - > does ANYTHING about this query strike you as odd? Lots of dead rows perhaps? The EXPLAIN estimates look a bit out of line --- 11483 cost units to fetch 47 index entries is an order or two of magnitude higher than it ought to be. The real time also seems to be concentrated in that index scan. What are the physical sizes of the table and index? (VACUUM VERBOSE output for the facility table might tell something.) regards, tom lane