Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsFhH-0000PN-8O for pgsql-performance@arkaria.postgresql.org; Wed, 13 Sep 2017 21:59:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dsFhF-0005Hj-S8 for pgsql-performance@arkaria.postgresql.org; Wed, 13 Sep 2017 21:59:49 +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 1dsFfU-00029g-3j for pgsql-performance@postgresql.org; Wed, 13 Sep 2017 21:58:00 +0000 Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dsFfQ-0005J3-RW for pgsql-performance@postgresql.org; Wed, 13 Sep 2017 21:57:59 +0000 Received: by mail-io0-x22b.google.com with SMTP id d16so9252284ioj.3 for ; Wed, 13 Sep 2017 14:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8V1OPJD28xt4R0Z7jO3eUDjObVT7xq9nv0E85evAa9k=; b=Xl1dIGqKifWfMRul+X8zX2JesyQzur9RZHo+neTVs+swYAhzXP1RemXX4yU692dw2P NKbvtnhbRgjG46fBKmaTN/ywkmBWZvnECXk1EiDujdMqacT5LozAXRwxSH392Af7KeDF lMyl/yNuekf1hv1Kf+Uf3vN1LrO2c0i1iP+44N0LDFNwSKF62K9u9TSFGQEX0l4XlrSj n2sMxkC96u3FBMSgnfmJzzCdV1ApAnvs6ghmQ5yacjRSnu1i9xjWbvPheo5oRa+dJgpI iZn3fIJLlWIfPOWinTrHIXl9AGYh6WmfjMY/VJ3lQyhWf+wUskaMWD26Sy2b5M4+fGCa qCjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8V1OPJD28xt4R0Z7jO3eUDjObVT7xq9nv0E85evAa9k=; b=niU8i37D3RBz8RSC0hiUwvB9rNQRzm7TNzRGdVa8K5NEip+lcNFkwV3jbq2jCHeBMo L0iMEjF812l++TyW9UKFP4eI8N8ME6jfXTnq43S6JQAmK3vypbZ5SsjkRZyukkx6uWJB cI0PDHxTMZC5PjbHxqX0+YcafLt6MKaWpoG7qIiNO6AhI66ILmWP5rI69/Bg70HS2inh H8DiPCkyKlwpefFugez5dB/xUBFOYCoTUks+ZorVG2o+bYkDn+1ziL6fzFNZCCzbAMb9 VyYnYpOpH4nNEJb2x72Wl08c40gA0T30wv5zNSK/Sw801/Jf//VL6YGDCQ3EexsNcAgE BnaQ== X-Gm-Message-State: AHPjjUiX2+JUuE3qRCteuU4MMtpRwiCMFsUklnaSvs1A7mJS6Lo47Xso kXpT5rcsUKr8HiiN3iQco2G0CcoV/Oj3pOvBkYrwiA== X-Google-Smtp-Source: AOwi7QDldNRYT7FEpbJYnDPukpyONG8eDxHTC/NMXRgSzAt4Szxb6C3ITH4siSf0CSelRGJ/7WpTxqzR5C2hHJmRC9g= X-Received: by 10.107.183.200 with SMTP id h191mr16556113iof.144.1505339874697; Wed, 13 Sep 2017 14:57:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.111.2 with HTTP; Wed, 13 Sep 2017 14:57:54 -0700 (PDT) In-Reply-To: References: From: David Rowley Date: Thu, 14 Sep 2017 09:57:54 +1200 Message-ID: Subject: Re: query of partitioned object doesnt use index in qa To: Mike Broers Cc: postgres performance list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On 14 September 2017 at 08:28, Mike Broers wrote: > I have a query of a partitioned table that uses the partition index in > production but uses sequence scans in qa. The only major difference I can > tell is the partitions are much smaller in qa. In production the partiti= ons > range in size from around 25 million rows to around 60 million rows, in QA > the partitions are between 4 and 12 million rows. I would think this wou= ld > be big enough to get the planner to prefer the index but this is the major > difference between the two database as far as I can tell. QA: > =E2=94=82 -> Seq Scan on event__99999999 e_1 > (cost=3D0.00..2527918.06 rows=3D11457484 width=3D782) =E2=94=82 > Production: > > =E2=94=82 -> Index Scan using > ix_event__00011162_landing_id on event__00011162 e_1 (cost=3D0.56..15476= .59 > rows=3D23400 width=3D572) =E2=94=82 If QA has between 4 and 12 million rows, then the planner's row estimate for the condition thinks 11457484 are going to match, so a Seqscan is likely best here. If those estimates are off then it might be worth double checking your nightly analyze is working correctly on QA. The planner may be able to be coaxed into using the index with a higher effective_cache_size and/or a lower random_page_cost setting, although you really should be looking at those row estimates first. Showing us the EXPLAIN ANALYZE would have been much more useful so that we could have seen if those are accurate or not. --=20 David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance