X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 57C4ADB01E for ; Thu, 10 Nov 2005 14:04:43 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39828-09 for ; Thu, 10 Nov 2005 18:04:41 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D6DC9DAF1B for ; Thu, 10 Nov 2005 14:04:41 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jAAI4fE6010462; Thu, 10 Nov 2005 13:04:41 -0500 (EST) To: Charlie Savage Cc: pgsql-performance@postgresql.org Subject: Re: Index Scan Costs versus Sort In-reply-to: References: Comments: In-reply-to Charlie Savage message dated "Thu, 10 Nov 2005 09:59:21 -0700" Date: Thu, 10 Nov 2005 13:04:41 -0500 Message-ID: <10461.1131645881@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200511/193 X-Sequence-Number: 15450 Charlie Savage writes: > 1. Postgresql estimates the index scan will be 50 times more costly > than the seq scan (112870376 vs 2229858) yet in fact it only takes 3 > times longer to execute (2312426 s vs. 768403 s). My understanding is > that postgresql assumes, via the random_page_cost parameter, that an > index scan will take 4 times longer than a sequential scan. So why is > the analyzer estimating it is 50 times slower? The other factors that are likely to affect this are index correlation and effective cache size. It's fairly remarkable that a full-table index scan only takes 3 times longer than a seqscan; you must have both a high correlation and a reasonably large cache. You showed us your effective_cache_size setting, but what's the pg_stats entry for completechain.tlid contain? Can you quantify what the physical ordering of tlid values is likely to be? regards, tom lane