Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TDqC5-0005Jv-Ux for pgsql-bugs@postgresql.org; Tue, 18 Sep 2012 05:17:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TDqC4-0004ek-HP for pgsql-bugs@postgresql.org; Tue, 18 Sep 2012 05:17:57 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q8I5HqdM004925; Tue, 18 Sep 2012 01:17:53 -0400 (EDT) From: Tom Lane To: "McGehee, Robert" cc: "pgsql-bugs@postgresql.org" Subject: Re: Incorrect Sort Using Index Scan In-reply-to: <17B09E7789D3104E8F5EEB0582A8D66FF24242683B@MSGRTPCCRF2WIN.DMN1.FMR.COM> References: <17B09E7789D3104E8F5EEB0582A8D66FF24242683B@MSGRTPCCRF2WIN.DMN1.FMR.COM> Comments: In-reply-to "McGehee, Robert" message dated "Mon, 17 Sep 2012 17:11:40 -0400" Date: Tue, 18 Sep 2012 01:17:52 -0400 Message-ID: <4924.1347945472@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) X-Archive-Number: 201209/183 X-Sequence-Number: 34178 "McGehee, Robert" writes: > I have recently upgraded to PostgreSQL 9.2.0 and one of my queries is now giving incorrectly sorted results due, I believe, to the new index-only scan in 9.2.0. The below table is a table of currency FX rates by date. Hmm, no it's not about index-only scans (your query isn't even using one). I think this got broken in my commit 9e8da0f75731aaa7605cf4656c21ea09e84d2eb1, which turned =ANY into a native index qualification type for btree. I thought that the output could still be considered sorted by the index's sort order, but this example proves that that's not so. Need to think a bit more carefully about that --- maybe we can only assume sorted output when the =ANY qual is for the first index column. Or maybe we can't assume it at all. regards, tom lane