Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jB8o2-0004aA-Ru for pgsql-performance@arkaria.postgresql.org; Mon, 09 Mar 2020 03:10:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jB8o1-0005SP-HG for pgsql-performance@arkaria.postgresql.org; Mon, 09 Mar 2020 03:10:13 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1jB8o1-0005Pd-3c for pgsql-performance@lists.postgresql.org; Mon, 09 Mar 2020 03:10:13 +0000 Received: from mail-yw1-xc43.google.com ([2607:f8b0:4864:20::c43]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jB8ny-0006yr-1N for pgsql-performance@lists.postgresql.org; Mon, 09 Mar 2020 03:10:12 +0000 Received: by mail-yw1-xc43.google.com with SMTP id i1so4616475ywf.4 for ; Sun, 08 Mar 2020 20:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=K4jNLqOL4Snrhcz77jts7iAAXhKUMcI9TN3rlfUacgg=; b=hhmIokalBLNPPf+RB0nglsxuH3E7sfHhz4y0EE7p5S+NNekYqJfItGDfMk7qGfTIHq gt/Qz4wM8X1INeyTnXgZRzlaeFslY0AbAWn3AWWXRmBWe0+CvWOrtTPZgk9HhXMaJlQX 5MJfMN5zv47bZu/deMWaZ+uOsypbnQn29A1rOjfvUbDIWXyzabYJ/zeO1O+9V/koB2P4 GnZu3fOWBZ60FoV2DbydAj4sGD+PSQnp6M1uIVJWGo1wq/BDeJCszzCO+aCj8ESxUMPF lNTvdw+Ule99iDI6VIJqqDoMoWSZOJJrb91czWBOavLZcccU0ijLlc4ekObPWEf/NsiL 2BnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=K4jNLqOL4Snrhcz77jts7iAAXhKUMcI9TN3rlfUacgg=; b=L+N0hJeugOEz6/uMmi+oygbJlYJR9OEztpusQSyfm0W/M0GnzP5fO9drsdePK8pEDJ T3JmxrFMool1PTPDnHd0Y6Q+tOEJnRXURoeWOSg4ybLZAixSS+RloYl/uNkJfkUSPOmb YUQXqB63T2BVJa2b5VvhbcuE+MTAlLmyIwJVamXOHiIW3rtmXLJDaWWxjYU4CQ9OgUvy RAa13oTnaLyjW5w7+I3apHJ3HUKIk1PRmVNTNE7dR3470e/2t7h8sGZD0aeIjSb9a6mM oS5P7q9ceejQfS/FEwxwvjzHpVh8uCzBei335IXYSWqT1mEAk44Zup1VfulCgKxnnV6B 0Lbw== X-Gm-Message-State: ANhLgQ1MX5JSPfki4vzccnH3MxHJnXJ9c05io76BsA5014XdbF3QSU6F cohkJ6cvZtfC5RfXyCX0tonBMQ== X-Google-Smtp-Source: ADFU+vvBIRCABspltu5op2ghSklDrORNnhKWAd8WwLlUzug9Y8QznwN/Acww5DhvYaxk+XKd9q54Jw== X-Received: by 2002:a25:7347:: with SMTP id o68mr15731567ybc.193.1583723407383; Sun, 08 Mar 2020 20:10:07 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id i124sm10367943ywa.81.2020.03.08.20.10.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Mar 2020 20:10:06 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 4C14D800926; Sun, 8 Mar 2020 22:10:05 -0500 (CDT) Date: Sun, 8 Mar 2020 22:10:05 -0500 From: Justin Pryzby To: Mariel Cherkassky Cc: pgsql-performance@lists.postgresql.org Subject: Re: pg12 partitions show bad performance vs pg96 Message-ID: <20200309031005.GE1357@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 08, 2020 at 06:05:26PM +0200, Mariel Cherkassky wrote: > In pg12 I created a table with 3 hash partitiones : > create table iot_data(id serial ,data text,metadata bigint,device bigint > references iot_device(id),primary key(id,device)) partition by hash(device); > and now for the performance: > query : explain analyze select * from iot_data da,iot_device de where > de.name in ('50a') and de.id = da.device and da.metadata=50 and > lower(da.data) like '50'; > I dont understand why in pg12 it scans all the partitions instead of the > relevant one.. As you noticed, it doesn't actually scan them. I believe v11 "partition elimination during query execution" is coming into play here. There's no option to disable that, but as a quick test, you could possibly try under PG10 (note, that doesn't support inherited indexes). Or you could try to profile under PG12 (and consider comparing with pg13dev). You partitioned on hash(iot_data.device), but your query doesn't specify device, except that da.device=de.id AND de.name IN ('50'). If that's a typical query, maybe it'd work better to partition on metadata or lower(name) (or possibly both). On Sun, Mar 08, 2020 at 06:05:26PM +0200, Mariel Cherkassky wrote: > PG12 : > Nested Loop (cost=5.16..773.61 rows=2 width=43) (actual time=2.858..2.858 > rows=0 loops=1) ... > -> Bitmap Heap Scan on iot_data_1 da_1 (cost=5.20..249.32 rows=2 > width=37) (NEVER EXECUTED) ... > Planning Time: 8.157 ms > Execution Time: 2.920 ms > PG96 : > Nested Loop (cost=6.57..397.19 rows=2 width=44) (actual time=0.121..0.121 > rows=0 loops=1) ... > Planning time: 0.815 ms > Execution time: 0.158 ms -- Justin