Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFsOJ-0000hb-FK for pgsql-performance@arkaria.postgresql.org; Sun, 11 Dec 2016 00:53:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cFsOI-00054d-Tf for pgsql-performance@arkaria.postgresql.org; Sun, 11 Dec 2016 00:53:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cFsMe-0003CV-Tt for pgsql-performance@postgresql.org; Sun, 11 Dec 2016 00:51:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cFsMc-000122-BG for pgsql-performance@postgresql.org; Sun, 11 Dec 2016 00:51:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id uBB0pX0c014794; Sat, 10 Dec 2016 19:51:34 -0500 From: Tom Lane To: Tomas Vondra cc: Eric Jiang , pgsql-performance@postgresql.org, Eric Clark Subject: Re: Querying with multicolumn index In-reply-to: References: <5353.1481327501@sss.pgh.pa.us> Comments: In-reply-to Tomas Vondra message dated "Sat, 10 Dec 2016 21:34:18 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14792.1481417493.1@sss.pgh.pa.us> Date: Sat, 10 Dec 2016 19:51:33 -0500 Message-ID: <14793.1481417493@sss.pgh.pa.us> X-Pg-Spam-Score: -4.9 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Tomas Vondra writes: > On 12/10/2016 12:51 AM, Tom Lane wrote: >> I tried to duplicate this behavior, without success. Are you running >> with nondefault planner parameters? > My guess is this is a case of LIMIT the matching rows are uniformly > distributed in the input data. The planner likely concludes that for a > driver with a lot of data we'll find the first row using ix_updates_time > very quickly, and that it will be cheaper than inspecting the larger > multi-column index. But imagine a driver with a lots of data long time > ago. That breaks the LIMIT fairly quickly. The fact that it's slow enough to be a problem is doubtless related to that effect. But AFAICS, the planner should never prefer that index for this query, because even with a uniform-density assumption, the index that really matches the query ought to look better. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance