Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwXqW-0008Jf-Pb for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Sep 2017 18:11:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dwXqW-0007Li-CT for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Sep 2017 18:11:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dwXqV-0007IZ-M1 for pgsql-bugs@postgresql.org; Mon, 25 Sep 2017 18:11:07 +0000 Received: from mail.aegee.org ([144.76.142.78]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwXqR-0005uI-Un for pgsql-bugs@postgresql.org; Mon, 25 Sep 2017 18:11:06 +0000 Authentication-Results: aegeeserv.aegee.org; auth=pass (PLAIN) smtp.auth=didopalauzov DKIM-Filter: OpenDKIM Filter v2.10.3 mail.aegee.org v8PICh6q029003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aegee.org; s=k4096; t=1506363164; i=dkim+MSA-tls@aegee.org; r=y; bh=oQWvZiVddKEsFfPm4e0iaTkaudiXzxZ/b8/Yvx1Tkm8=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=aUHDDt4GPWQit5mmnWHFz63omTD4FMp1n0AIZkYg7Z9kJxH2hqA0KCOkgMVWocj/y 8npmTtK8yFMqhAMkwrp35h24oayslt33DOZCGaPEv+vARz1hT5Sz9Y4cEuYa+CjkbX /1uTkgrKQz+AM5M+2SS07cG4SOX1XANuiBfMf6Nmm1Asek1cZrc4Csok/rDGB9rS0e wGlqXGu9NI3WQs9SSkrvVb/YUjc25C8ii16dt/K8iPJQmdXbhhfke5inw6P5DeaKDy 0IinmoS3uK50sZ8bGHffSnv3ZiASlERc3jxZ70+7xl5WMquKx+LrCZfzMB7O8TKTJE pwOvR2cp9SXEdNKRd6OLB8hmFcMAavf8v2sZAjR9eBYSe9ViyPswbDeBDe59bpB9p/ AewfNhUkZgGNLaya+QZN0wFtZud1y45oowcUhyLMf5p7CqKVtYmr+IDMZlRo6yT8Q4 /s5AeflvCQhNS78jNFoYT6bpO2SEnPnuRBERm20jd7rBhfW7sgusgHudOG9D5fy+/C LFhq0Xz/GfGgfDZxkDI4L0k03pC4/6f1UQiYr+4lRfEXCKafAfHg/5xqCfrCfzAoc5 5lfatjKi1EwXjIFyMaDh5HWVCszIdRu7RcpVBoQHjuQmgdLDWn7KMspjetq9aNKlft a63rPpupaPRujGkFE2IbcBls= Authentication-Results: mail.aegee.org; dkim=none Received: from [10.128.8.92] (port-87-193-154-82.static.qsc.de [87.193.154.82]) (authenticated bits=0) by mail.aegee.org (8.15.2/8.15.2) with ESMTPSA id v8PICh6q029003 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 25 Sep 2017 18:12:44 GMT Subject: Re: Query planner skipping index depending on DISTINCT parameter order (2) To: Greg Stark , Tom Lane Cc: Tomas Vondra , PostgreSQL Bugs References: <3c651d99-a943-4e21-4ec9-604b142c85e0@aegee.org> <57ccc03b-279a-63f7-19c6-6fe3b2d0e1be@aegee.org> <271e4961-abfa-06ef-a502-cf00a31b236a@2ndquadrant.com> <12044.1505668534@sss.pgh.pa.us> From: =?UTF-8?B?0JTQuNC70Y/QvSDQn9Cw0LvQsNGD0LfQvtCy?= Message-ID: <6e8b3a9b-9b3d-e655-4456-f91a1ea3292b@aegee.org> Date: Mon, 25 Sep 2017 20:10:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.99.2 at mail.aegee.org X-Virus-Status: Clean 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, for the record, in this table spamassassin=> \d bayes_token Table "public.bayes_token" Column Type Modifiers ────────── ─────── ──────────────────────────── id integer not null default 0 token bytea not null default '\x'::bytea spam_count integer not null default 0 ham_count integer not null default 0 atime integer not null default 0 Indexes: "bayes_token_pkey" PRIMARY KEY, btree (id, token) "bayes_token_idx1" btree (token) "SELECT id, token FROM bayes_token" and "SELECT id, token FROM bayes_token WHERE id > 0" do Seq Scan and need 35-50 Sec. But "SELECT id, token FROM bayes_token WHERE id > 1" uses Index Only Scan and 0.04 seconds on pg 9.6.5 . Greetings Dilian On 09/25/17 12:43, Greg Stark wrote: > On 17 September 2017 at 18:15, Tom Lane wrote: > >> For plain DISTINCT, yeah we could consider other orderings ... but >> we're rather unlikely to find an index that matches all the output >> columns, regardless of what order they're in. So it's just not that >> exciting. > > I don't follow this part. Are you saying a simple "select distinct a,b > from table" is unlikely to find a matching index on ? Don't we > already do exactly this for "select a,b from table group by a,b"? I > would have expected the two equivalent SQL statements to use exactly > the same infrastructure and thought it was only a matter of historical > legacy that they didn't. > -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs