X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 75C759F946D for ; Mon, 22 May 2006 12:26:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 54426-05 for ; Mon, 22 May 2006 12:26:00 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 30B289F9316 for ; Mon, 22 May 2006 12:25:59 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id 39C2856435; Mon, 22 May 2006 10:25:56 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Mon, 22 May 2006 10:25:54 -0500 Date: Mon, 22 May 2006 10:25:51 -0500 From: "Jim C. Nasby" To: Brendan Duddridge Cc: Ragnar , PostgreSQL Performance Subject: Re: Performs WAY better with enable_seqscan = off Message-ID: <20060522152549.GO64371@pervasive.com> References: <1148208611.28240.101.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060522:brendan@clickspace.com::Yj0UWf9pA8ZFJvPm:000000000000000 0000000000000000000000001g1V X-Hashcash: 1:20:060522:gnari@hive.is::Hix/SskWJchKun0p:000014T0 X-Hashcash: 1:20:060522:pgsql-performance@postgresql.org::tYG6dK9VgZsjHZH7:00000 0000000000000000000000009hC7 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/418 X-Sequence-Number: 19205 On Sun, May 21, 2006 at 02:01:14PM -0600, Brendan Duddridge wrote: > When the query planner uses the indexes with the concatenated values > and the where clause, the query can be sub-second response times (but > not always depending on the category_id value). By just doing a > regular join as you suggested, it's always slower. The trick is > getting Postgres to use the proper index all the time. And so far the > only way I can do that is by turning off sequential scans, but that's > something I didn't want to do because I don't know how it would > affect the performance of the rest of my application. You can always disable them for just that query... BEGIN; SET LOCAL enable_seqscan=off; SELECT ... COMMIT; > Just a note, I have random_page_cost set to 1 to try and get it to > favour index scans. The database machine has 8GB of RAM and I have > effective_cache_size set to 2/3 of that. That's rather low for that much memory; I'd set it to 7GB. -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461