Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCq3c-0002CX-3Y for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Feb 2014 12:33:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WCq3b-0000CH-FY for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Feb 2014 12:33:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCq3a-0000CB-LQ for pgsql-bugs@postgresql.org; Mon, 10 Feb 2014 12:33:50 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCq3X-00071n-9u for pgsql-bugs@postgresql.org; Mon, 10 Feb 2014 12:33:50 +0000 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 30AFB2094C for ; Mon, 10 Feb 2014 07:33:45 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Mon, 10 Feb 2014 07:33:45 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=imap.cc; h= message-id:date:from:mime-version:to:subject:content-type :content-transfer-encoding; s=mesmtp; bh=ClHzdHwIpWYatdCwMAbLan/ 1/nY=; b=ajg0t3ipnVueisWi8ZV5NWJz/fX23i+T5ruwv9Y5Av6EPo65xeeCcPl C3OER2c1E2HMVSHBuel1P60oa9p34PNR+kU9bntscNkV9tWoXxnQh7tdmdgaZPlo VoBetWvBk0GM8Ejoe66t71XxWetfzODRtSc1GNTOHZPrTZzLgSNs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:content-type:content-transfer-encoding; s=smtpout; bh=C lHzdHwIpWYatdCwMAbLan/1/nY=; b=ncBcShiIEyKyG5Xgl89xtolBAgbkUIHv1 Bx+ooSrRGmkkNvAMFkzn3/4QQ7jXRbZ0ymq0DLZ0rc6hR50sup1vWAZKt06KakIT FS9vGdt7Zw8/Aa2Js0DawOiIvjYveVds44nvBPoGSiP1xEQMI4XVhr4YV5hNJPK6 9q3s2ACbJ8= X-Sasl-enc: 8RWtaYrO+9N+rRDq7o3PO8dG/i+Aby+/bFZbcpBh2mnW 1392035624 Received: from [192.168.1.23] (unknown [195.91.155.97]) by mail.messagingengine.com (Postfix) with ESMTPA id BFAAA6800F1 for ; Mon, 10 Feb 2014 07:33:44 -0500 (EST) Message-ID: <52F8C727.3020409@imap.cc> Date: Mon, 10 Feb 2014 16:33:43 +0400 From: Alexey Bashtanov User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: index scan is performed when index-only scan is possible (partial index) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hello! It seems to me there is a situation where index-only scan is possible but not performed. ----- [ACTIONS] > create table t as select a, a % 2 b, a % 2 c from generate_series(1, 1000000) a order by random(); SELECT 1000000 > create index t_i1 on t (a, c) where b = 1; CREATE INDEX > analyze t; ANALYZE > EXPLAIN select a from t where a < 10000 and b = 1 order by a; QUERY PLAN --------------------------------------------------------------------- Index Scan using t_i1 on t (cost=0.42..14013.07 rows=5094 width=4) Index Cond: (a < 10000) (2 rows) > create index t_i2 on t (a, b) where b = 1; CREATE INDEX > EXPLAIN select a from t where a < 10000 and b = 1 order by a; QUERY PLAN -------------------------------------------------------------------------- Index Only Scan using t_i2 on t (cost=0.42..14009.07 rows=5094 width=4) Index Cond: ((a < 10000) AND (b = 1)) (2 rows) [EXPECTED] in both cases index-only scan is performed [RECEIVED] in the first case index scan is performed, though index-only scan is possible, as no conditions rechecking is required ----- adding (b=1) expression to index as a column does not help Regards, Alexey -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs