X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 9A11E9FB1BC for ; Sat, 22 Jul 2006 15:27:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 13368-09 for ; Sat, 22 Jul 2006 18:27:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net [70.167.125.69]) by postgresql.org (Postfix) with ESMTP id 2D5EF9FA6B0 for ; Sat, 22 Jul 2006 15:27:17 -0300 (ADT) Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id k6MIR6n1004878; Sat, 22 Jul 2006 11:27:06 -0700 Message-ID: <44C25FDD.8070003@modgraph-usa.com> Date: Sat, 22 Jul 2006 10:26:53 -0700 From: "Craig A. James" User-Agent: Thunderbird 1.5.0.4 (X11/20060516) MIME-Version: 1.0 To: Tom Lane CC: robin.c.smith@bt.com, pgsql-performance@postgresql.org Subject: Re: Forcing using index instead of sequential scan? References: <26827.1153585341@sss.pgh.pa.us> In-Reply-To: <26827.1153585341@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200607/221 X-Sequence-Number: 20081 > The real issue here is caching across successive queries, an effect that > Postgres doesn't deal with very well at the moment. If you run these > queries from a standing start (freshly booted machine) you'll likely > find that the indexscan plan is indeed slower than the seqscan/hash > plan, just like the planner thinks. Here's a little trick I learned to speed up this test. find / -type f -exec grep foobar {} \; This causes massive file-system activity and flushes all files that the kernel has cached. If you run this between each Postgres test (let it run for a couple minutes), it gives you an apples-to-apples comparison between successive benchmarks, and eliminates the effects of caching. If you run this as a regular user (NOT super-user or 'postgres'), you won't have permission to access your Postgres files, so you're guaranteed they'll be flushed from the cache. Craig