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 30F609F9316 for ; Thu, 18 May 2006 14:34:46 -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 47645-05-4 for ; Thu, 18 May 2006 14:34:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 1DDCD9F9C18 for ; Thu, 18 May 2006 14:34:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4IHYJP8016020; Thu, 18 May 2006 13:34:19 -0400 (EDT) To: "Steinar H. Gunderson" cc: pgsql-performance@postgresql.org, Stephen Byers Subject: Re: why is bitmap index chosen for this query? In-reply-to: <20060518164640.GA7291@uio.no> References: <20060518155906.GA6909@uio.no> <20060518164123.98856.qmail@web30710.mail.mud.yahoo.com> <20060518164640.GA7291@uio.no> Comments: In-reply-to "Steinar H. Gunderson" message dated "Thu, 18 May 2006 18:46:40 +0200" Date: Thu, 18 May 2006 13:34:19 -0400 Message-ID: <16019.1147973659@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/395 X-Sequence-Number: 19182 "Steinar H. Gunderson" writes: > What about the working set? Have you tried running the queries multiple times > in a row to see if the results change? It might be that your initial bitmap > scan puts all the relevant bits into cache, which will skew the results. If the examples were done in the order shown, the seqscan ought to have pretty well blown out the cache ... but I concur that it'd be interesting to check whether repeated executions of the same plan show markedly different times. Also, is the index order closely correlated to the actual physical table order? What is work_mem set to, and does increasing it substantially make the bitmap scan work any better? Considering that the query is fetching about half of the table, I'd have thought that the planner was correct to estimate that bitmap or seqscan ought to win. For the plain indexscan to win, the order correlation must be quite strong, and I'm also guessing that the bitmap scan must have run into some substantial trouble (like discarding a lot of info because of lack of work_mem). IIRC, the planner doesn't currently try to model the effects of a bitmap scan going into lossy mode, which is something it probably should try to account for. regards, tom lane