Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8CF1A133729E for ; Fri, 15 Oct 2010 15:29:36 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21860-05 for ; Fri, 15 Oct 2010 18:29:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 67AE01335B36 for ; Fri, 15 Oct 2010 15:29:28 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9FITRUf007092; Fri, 15 Oct 2010 14:29:27 -0400 (EDT) To: Nikolai Zhubr cc: pgsql-performance@postgresql.org Subject: Re: Index scan / Index cond limitation or ? In-reply-to: <4CB7268D.4060901@yandex.ru> References: <4CB7268D.4060901@yandex.ru> Comments: In-reply-to Nikolai Zhubr message dated "Thu, 14 Oct 2010 19:49:33 +0400" Date: Fri, 15 Oct 2010 14:29:27 -0400 Message-ID: <7091.1287167367@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/260 X-Sequence-Number: 40678 Nikolai Zhubr writes: > So, "in (1, 2)" condition is not in Index Cond anymore! Why is that? How > can I push it back? It thinks the indexscan condition is sufficiently selective already. An = ANY condition like that will force multiple index searches, one for each of the OR'd possibilities, so it's far from "free" to add it to the index condition. The planner doesn't think it's worth it. Perhaps on your real query it is, but there's not much point in debating about the behavior on this toy table; without realistic table sizes and up-to-date stats it's impossible to say whether that choice is correct or not. > SELECT version(); > PostgreSQL 8.3.1, compiled by Visual C++ build 1400 You really, really, really ought to be running 8.3.something-newer. We didn't put out the last 11 8.3.x bugfix updates just because we didn't have anything better to do. regards, tom lane