Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 83B7864FEDB for ; Thu, 30 Oct 2008 21:19:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54134-02 for ; Thu, 30 Oct 2008 21:19:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.01.com (lb-2.01.com [38.98.186.147]) by postgresql.org (Postfix) with ESMTP id B9CB264FD24 for ; Thu, 30 Oct 2008 21:19:14 -0300 (ADT) Received: from asav-2.01.com (localhost.localdomain [127.0.0.1]) by asav-2.01.com (8.13.1/8.13.1) with SMTP id m9V0J7Yv004112 for ; Thu, 30 Oct 2008 19:19:07 -0500 Received: from smtp-1.01.com (smtp-1.01.com [38.98.186.157]) by asav-2.01.com (asav-2.01.com [10.25.1.12]) id k9YJJ72278862355a2 ret-id none; Thu, 30 Oct 2008 19:19:07 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-1.01.com (Postfix) with ESMTP id 27E5F364018 for ; Thu, 30 Oct 2008 19:19:07 -0500 (CDT) Received: from smtp-1.01.com ([127.0.0.1]) by localhost (smtp-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZK0JvZuFOCXd for ; Thu, 30 Oct 2008 19:19:07 -0500 (CDT) Received: from [10.10.10.18] (8.202-62-69.ftth.swbr.surewest.net [69.62.202.8]) by smtp-1.01.com (Postfix) with ESMTP id DA3EFE0C87 for ; Thu, 30 Oct 2008 19:19:06 -0500 (CDT) Message-ID: <490A4EBE.9030804@frostconsultingllc.com> Date: Thu, 30 Oct 2008 17:18:06 -0700 From: Jeff Frost Organization: Frost Consulting, LLC User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Index usage problem on 8.3.3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-FSL-MailScanner-Information: Please contact postmaster@01.com for more information X-FSL-MailScanner: Found to be clean X-FSL-MailScanner-SpamCheck: X-FSL-MailScanner-From: jeff@frostconsultingllc.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/136 X-Sequence-Number: 31717 I've run across a strange problem with PG 8.3.3 not using indexes on a particular table after building the table during a transaction. You can see a transcript of the issue here: http://gist.github.com/21154 Interestingly, if I create another temp table 'CREATE TEMP TABLE AS SELECT * FROM act' as seen on line 107, then add the same indexes to that table, PG will use the indexes. While it's not in the gist transcript, even an extremely simple query like: SELECT * FROM act WHERE act_usr_id = 1; will not use the index on the original act table, but the jefftest and jefftest2 tables both work fine. As you can probably see in the transcript, the tables have been ANALYZEd. I even tried 'enable seqscan=0;' and that made the cost really high for the seq scan, but the planner still chose the seq scan. The issue does not affect 8.2.3 nor does it affect 8.3.4. I didn't see any mention of a fix for this sort of thing in 8.3.4's release notes. I was wondering if this is a known bug in 8.3.3 (and maybe other 8.3.x versions) and just didn't make it into the release notes of 8.3.4? -- Jeff Frost, Owner Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 916-647-6411 FAX: 916-405-4032