Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B2A989F99C1 for ; Thu, 16 Aug 2007 14:01:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 83712-08 for ; Thu, 16 Aug 2007 14:01:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id A609B9FA1A7 for ; Thu, 16 Aug 2007 14:01:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l7GH1O6a006238; Thu, 16 Aug 2007 13:01:24 -0400 (EDT) To: Frank Schoep cc: pgsql-performance@postgresql.org Subject: Re: Bad planner decision - bitmap scan instead of index In-reply-to: References: Comments: In-reply-to Frank Schoep message dated "Thu, 16 Aug 2007 18:14:02 +0200" Date: Thu, 16 Aug 2007 13:01:24 -0400 Message-ID: <6237.1187283684@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/161 X-Sequence-Number: 26291 Frank Schoep writes: > Limit (cost=4002.04..4002.29 rows=100 width=48) (actual > time=1469.565..1470.097 rows=100 loops=1) > -> Sort (cost=3997.29..4031.18 rows=13556 width=48) (actual > time=1460.958..1467.993 rows=2000 loops=1) > Sort Key: name > -> Bitmap Heap Scan on movies (cost=86.45..3066.90 > rows=13556 width=48) (actual time=20.522..77.889 rows=13640 loops=1) > Recheck Cond: (letter = 'T'::bpchar) > -> Bitmap Index Scan on movies_letter > (cost=0.00..86.45 rows=13556 width=0) (actual time=18.452..18.452 > rows=13658 loops=1) > Index Cond: (letter = 'T'::bpchar) > Total runtime: 1474.821 ms Why is the sort step so slow? Sorting a mere 13k rows shouldn't take very long. Maybe you are overrunning work_mem and it's falling back to a disk sort ... what is work_mem set to? Another theory is that you are using a locale in which strcoll() is horridly expensive :-( regards, tom lane