Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 62E709F9BB3 for ; Thu, 4 Oct 2007 20:43:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 10047-03 for ; Thu, 4 Oct 2007 20:43:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from lists.commandprompt.com (host-254.commandprompt.net [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id 6DB009F9B9B for ; Thu, 4 Oct 2007 20:43:36 -0300 (ADT) Received: from perhan.alvh.no-ip.org (201-220-98-36.bk9-dsl.surnet.cl [201.220.98.36]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id l94NhWb1009869; Thu, 4 Oct 2007 16:43:34 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 2A10E47C6E; Thu, 4 Oct 2007 19:43:31 -0400 (CLT) Date: Thu, 4 Oct 2007 19:43:31 -0400 From: Alvaro Herrera To: Henrik Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Query taking too long. Problem reading explain output. Message-ID: <20071004234331.GG28896@alvh.no-ip.org> References: <15793.1191420918@sss.pgh.pa.us> <2E2D02AB-123A-474D-A197-91A61DC64570@mac.se> <20071004123038.GA6176@alvh.no-ip.org> <8DEE0C69-B3A8-4ED5-AECB-4C7C398C8421@mac.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8DEE0C69-B3A8-4ED5-AECB-4C7C398C8421@mac.se> User-Agent: Mutt/1.5.16 (2007-06-11) X-Virus-Scanned: ClamAV 0.91.1/4466/Wed Oct 3 22:05:43 2007 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Thu, 04 Oct 2007 16:43:35 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/52 X-Sequence-Number: 27074 Henrik wrote: > Correct. I changed the statistics to 500 in tbl_file.file_name and now the > statistics is better. But now my big seq scan on tbl_file_Structure back > and I don't know why. Hmm, I think the problem here is that it needs to fetch ~200000 tuples from tbl_file_structure one way or the other. When it misestimated the tuples from tbl_file it thought it would only need to do the indexscan in tbl_file_structure a few times, but now it realizes that it needs to do it several thousands of times and it considers the seqscan to be cheaper. Perhaps you would benefit from a higher effective_cache_size or a lower random_page_cost (or both). I think this is a problem in the optimizer: it doesn't correctly take into account the fact that the upper pages of the index are most likely to be cached. This has been discussed a lot of times but it's not a simple problem to fix. -- Alvaro Herrera http://www.amazon.com/gp/registry/CTMLCN8V17R4 Este mail se entrega garantizadamente 100% libre de sarcasmo.