Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC99r-0007MH-Hn for pgsql-bugs@arkaria.postgresql.org; Mon, 15 Oct 2018 20:08:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gC99p-0005A1-FT for pgsql-bugs@arkaria.postgresql.org; Mon, 15 Oct 2018 20:08:05 +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.89) (envelope-from ) id 1gC8ZS-0004HK-26 for pgsql-bugs@lists.postgresql.org; Mon, 15 Oct 2018 19:30:30 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gC8ZP-0007zy-2o for pgsql-bugs@lists.postgresql.org; Mon, 15 Oct 2018 19:30:28 +0000 Received: by mail-ed1-x532.google.com with SMTP id y20-v6so18957129eds.10 for ; Mon, 15 Oct 2018 12:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=S7XkAChMpqkjSFCCxSDVZ/bYhLVeNNzOrMs9tBIOLGI=; b=np+HJ7LWpjGPnL9yDgUVWoIN/+OOxAAjlfj31lkLo0xLkCaKf+wNyvFVTYCJPgcRmc c1p1alIACbRlfoMvoqXaTpyyd3xuMVF/xUxjDNMGodrn8/QC8RnmJEQ2k8DucXL/HDaA CrsOiSvLybCJoKAhL3d4M7K8Loyr2WftvWGVVE3Tr1qojE7rjPI8dZAS4NdHOVWzlInK X7y1e2DmXgc5G/+eC3/4Sf//WS7PPGPsfouQ8Oq/gY1pK4I3650CcqZs8y2hUz8atb/k KYj1kKIM2YC0cHt0Yh+HN8MrbY8Qz/9pAb2gC2CdWj5ZVhUyPMkyWICBxUFdNRk2cXTP SRDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=S7XkAChMpqkjSFCCxSDVZ/bYhLVeNNzOrMs9tBIOLGI=; b=SBeMvzK4p117MFiugON23loNqEIj3Zsp4HwIWkurM9JHIuIKoNUdk4KfzPi0puh59a /f/scLgpGD7WMprAAJ/5UYvmfbJDiZkTotlexA70grgcTRFfc5eCuBgeLpTo6Lwnt+HB 7hF3JxLg+MQOem0lxMmT1r6+jCXT3QTJq9UlteVWsp4NLrTylY1Gvh3sX1x39NC25ca5 S25JIdXC0PFMmvG0lKZZvTbFfNo63c10KyVPA25DVIWG7w1S2tuI1A2/tbgJ+ZVA+8I8 SxXa9jjads4FIkX+oMb6sJHIVNsHdXDMcckFvHQEWSQAQ8g8oAHHBl2HOzVH7HJiB6iy CfwQ== X-Gm-Message-State: ABuFfoiK3BA0UYdm8PL3ytFiX/5PEt1A6snGCYcnyI3jzMK9/tY4hXWi Dl3w96l5kQW82nIZVDVzxhI= X-Google-Smtp-Source: ACcGV634XDv3kZ7Z0g0Wdt5wCynt1W0BbUrdE1bEe43GZtB6SDaBIX8q/yIDHUzHnRQ9V8bNL7eFgQ== X-Received: by 2002:a50:c94b:: with SMTP id p11-v6mr26329728edh.6.1539631825362; Mon, 15 Oct 2018 12:30:25 -0700 (PDT) Received: from [172.20.10.12] ([109.140.231.151]) by smtp.gmail.com with ESMTPSA id 7-v6sm2380669ejy.11.2018.10.15.12.30.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 12:30:24 -0700 (PDT) From: Bart D Message-Id: <20BCBC3B-6F69-46C4-8EB1-FCF77BBF9FF1@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_06DB298F-83D6-4022-AE39-F431873B0810" Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: BUG #15430: partition-wise join only works in combination with pruning on 1 partition Date: Mon, 15 Oct 2018 21:30:22 +0200 In-Reply-To: Cc: pgsql-bugs@lists.postgresql.org, PG Bug reporting form To: Amit Langote References: <15430-ee54c4208e54e9b1@postgresql.org> X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_06DB298F-83D6-4022-AE39-F431873B0810 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Amit, You are right, I think the feature should be enabled by default though. This feature guarantees linear scalability. My apologies, please close the bug. Please find results below. Thanks in advance, psql <<-EOF show enable_partitionwise_join; set enable_partitionwise_join =3D on; show enable_partitionwise_join; explain=20 select *=20 from=20 part_test.measurement m1 inner join part_test.measurement2 m2 on m1.city_id =3D m2.city_id and m1.logdate =3D m2.logdate EOF # Append (cost=3D257.79..573.65 rows=3D172 width=3D32) # -> Merge Join (cost=3D257.79..286.40 rows=3D86 width=3D32) # Merge Cond: ((m1.city_id =3D m2.city_id) AND (m1.logdate =3D = m2.logdate)) # -> Sort (cost=3D128.89..133.52 rows=3D1850 width=3D16) # Sort Key: m1.city_id, m1.logdate # -> Seq Scan on measurement_y2006m02 m1 = (cost=3D0.00..28.50 rows=3D1850 width=3D16) # -> Sort (cost=3D128.89..133.52 rows=3D1850 width=3D16) # Sort Key: m2.city_id, m2.logdate # -> Seq Scan on measurement2_y2006m02 m2 = (cost=3D0.00..28.50 rows=3D1850 width=3D16) # -> Merge Join (cost=3D257.79..286.40 rows=3D86 width=3D32) # Merge Cond: ((m1_1.city_id =3D m2_1.city_id) AND (m1_1.logdate = =3D m2_1.logdate)) # -> Sort (cost=3D128.89..133.52 rows=3D1850 width=3D16) # Sort Key: m1_1.city_id, m1_1.logdate # -> Seq Scan on measurement_y2006m03 m1_1 = (cost=3D0.00..28.50 rows=3D1850 width=3D16) # -> Sort (cost=3D128.89..133.52 rows=3D1850 width=3D16) # Sort Key: m2_1.city_id, m2_1.logdate # -> Seq Scan on measurement2_y2006m03 m2_1 = (cost=3D0.00..28.50 rows=3D1850 width=3D16) psql <<-EOF show enable_partitionwise_join; set enable_partitionwise_join =3D on; show enable_partitionwise_join; explain=20 select *=20 from=20 part_test.measurement m1 inner join part_test.measurement2 m2 on m1.city_id =3D m2.city_id and m1.logdate =3D m2.logdate where m1.logdate in ('2006-02-01'::date, '2006-03-01'::date) EOF # Append (cost=3D33.40..160.82 rows=3D2 width=3D32) # -> Hash Join (cost=3D33.40..80.41 rows=3D1 width=3D32) # Hash Cond: ((m2.city_id =3D m1.city_id) AND (m2.logdate =3D = m1.logdate)) # -> Seq Scan on measurement2_y2006m02 m2 (cost=3D0.00..28.50 = rows=3D1850 width=3D16) # -> Hash (cost=3D33.12..33.12 rows=3D18 width=3D16) # -> Seq Scan on measurement_y2006m02 m1 = (cost=3D0.00..33.12 rows=3D18 width=3D16) # Filter: (logdate =3D ANY = ('{2006-02-01,2006-03-01}'::date[])) # -> Hash Join (cost=3D33.40..80.41 rows=3D1 width=3D32) # Hash Cond: ((m2_1.city_id =3D m1_1.city_id) AND (m2_1.logdate = =3D m1_1.logdate)) # -> Seq Scan on measurement2_y2006m03 m2_1 (cost=3D0.00..28.50 = rows=3D1850 width=3D16) # -> Hash (cost=3D33.12..33.12 rows=3D18 width=3D16) # -> Seq Scan on measurement_y2006m03 m1_1 = (cost=3D0.00..33.12 rows=3D18 width=3D16) # Filter: (logdate =3D ANY = ('{2006-02-01,2006-03-01}'::date[])) > On 15 Oct 2018, at 06:18, Amit Langote = wrote: >=20 > Hi, >=20 > On 2018/10/15 0:20, PG Bug reporting form wrote: >> The following bug has been logged on the website: >>=20 >> Bug reference: 15430 >> Logged by: Bart Debersaques >> Email address: agile.data.analytics@gmail.com >> PostgreSQL version: 11rc1 >> Operating system: Centos 7 >> Description: =20 >=20 > [ ... ] >=20 >> psql <<-EOF >> explain=20 >> select *=20 >> from=20 >> part_test.measurement m1 >> inner join part_test.measurement2 m2 >> on m1.city_id =3D m2.city_id and m1.logdate =3D m2.logdate >> where m1.logdate in ('2006-02-01'::date, '2006-03-01'::date) > EOF >> # Hash Join (cost=3D66.97..170.25 rows=3D3 width=3D32) >> # Hash Cond: ((m2.city_id =3D m1.city_id) AND (m2.logdate =3D = m1.logdate)) >> # -> Append (cost=3D0.00..75.50 rows=3D3700 width=3D16) >> # -> Seq Scan on measurement2_y2006m02 m2 (cost=3D0.00..28.50= >> rows=3D1850 width=3D16) >> # -> Seq Scan on measurement2_y2006m03 m2_1 = (cost=3D0.00..28.50 >> rows=3D1850 width=3D16) >> # -> Hash (cost=3D66.43..66.43 rows=3D36 width=3D16) >> # -> Append (cost=3D0.00..66.43 rows=3D36 width=3D16) >> # -> Seq Scan on measurement_y2006m02 m1 = (cost=3D0.00..33.12 >> rows=3D18 width=3D16) >> # Filter: (logdate =3D ANY >> ('{2006-02-01,2006-03-01}'::date[])) >> # -> Seq Scan on measurement_y2006m03 m1_1 = (cost=3D0.00..33.12 >> rows=3D18 width=3D16) >> # Filter: (logdate =3D ANY >> ('{2006-02-01,2006-03-01}'::date[])) >>=20 >> # conclusion: join performed on full tab scans, join not performed on = a >> per-partion basis >=20 > Have you changed the value of enable_partitionwise_join parameter to = 'on'? > It's 'off' by default, so join is not performed on per-partition = basis. >=20 > Thanks, > Amit >=20 --Apple-Mail=_06DB298F-83D6-4022-AE39-F431873B0810 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Amit,

You are right, I = think the feature should be enabled by default though.

This feature guarantees linear scalability.

My apologies, please close the bug.

Please find results below.

Thanks in advance,



psql <<-EOF
show = enable_partitionwise_join;
set enable_partitionwise_join =3D = on;
show enable_partitionwise_join;
explain 
select * 
from 
part_test.measurement m1
inner = join part_test.measurement2 m2
on m1.city_id =3D m2.city_id and = m1.logdate =3D m2.logdate
EOF
# Append  (cost=3D257.79..573.65 = rows=3D172 width=3D32)
#   ->  Merge Join  = (cost=3D257.79..286.40 rows=3D86 width=3D32)
#     =     Merge Cond: ((m1.city_id =3D m2.city_id) AND (m1.logdate =3D= m2.logdate))
#         ->  Sort  = (cost=3D128.89..133.52 rows=3D1850 width=3D16)
#     =           Sort Key: m1.city_id, = m1.logdate
#               = ->  Seq Scan on measurement_y2006m02 m1  (cost=3D0.00..28.50 = rows=3D1850 width=3D16)
#         ->  = Sort  (cost=3D128.89..133.52 rows=3D1850 width=3D16)
#   =             Sort Key: m2.city_id, = m2.logdate
#               = ->  Seq Scan on measurement2_y2006m02 m2  (cost=3D0.00..28.50= rows=3D1850 width=3D16)
#   ->  Merge Join  = (cost=3D257.79..286.40 rows=3D86 width=3D32)
#     =     Merge Cond: ((m1_1.city_id =3D m2_1.city_id) AND = (m1_1.logdate =3D m2_1.logdate))
#         = ->  Sort  (cost=3D128.89..133.52 rows=3D1850 = width=3D16)
#               Sort = Key: m1_1.city_id, m1_1.logdate
#           =     ->  Seq Scan on measurement_y2006m03 m1_1  = (cost=3D0.00..28.50 rows=3D1850 width=3D16)
#     =     ->  Sort  (cost=3D128.89..133.52 rows=3D1850 = width=3D16)
#               Sort = Key: m2_1.city_id, m2_1.logdate
#           =     ->  Seq Scan on measurement2_y2006m03 m2_1  = (cost=3D0.00..28.50 rows=3D1850 width=3D16)

psql <<-EOF
show = enable_partitionwise_join;
set enable_partitionwise_join =3D = on;
show enable_partitionwise_join;
explain 
select * 
from 
part_test.measurement m1
inner = join part_test.measurement2 m2
on m1.city_id =3D m2.city_id and = m1.logdate =3D m2.logdate
where m1.logdate in ('2006-02-01'::date, = '2006-03-01'::date)
EOF
# Append  (cost=3D33.40..160.82 rows=3D2 = width=3D32)
#   ->  Hash Join  (cost=3D33.40..80.41= rows=3D1 width=3D32)
#         Hash Cond: = ((m2.city_id =3D m1.city_id) AND (m2.logdate =3D m1.logdate))
#   =       ->  Seq Scan on measurement2_y2006m02 = m2  (cost=3D0.00..28.50 rows=3D1850 width=3D16)
#   =       ->  Hash  (cost=3D33.12..33.12 rows=3D18= width=3D16)
#               = ->  Seq Scan on measurement_y2006m02 m1  (cost=3D0.00..33.12 = rows=3D18 width=3D16)
#             =         Filter: (logdate =3D ANY = ('{2006-02-01,2006-03-01}'::date[]))
#   ->  Hash Join  = (cost=3D33.40..80.41 rows=3D1 width=3D32)
#         = Hash Cond: ((m2_1.city_id =3D m1_1.city_id) AND (m2_1.logdate =3D = m1_1.logdate))
#         ->  = Seq Scan on measurement2_y2006m03 m2_1  (cost=3D0.00..28.50 = rows=3D1850 width=3D16)
#         ->  = Hash  (cost=3D33.12..33.12 rows=3D18 width=3D16)
#   =             ->  Seq Scan on = measurement_y2006m03 m1_1  (cost=3D0.00..33.12 rows=3D18 = width=3D16)
#               =       Filter: (logdate =3D ANY = ('{2006-02-01,2006-03-01}'::date[]))

On 15 Oct 2018, at 06:18, Amit = Langote <Langote_Amit_f8@lab.ntt.co.jp> wrote:

Hi,
On 2018/10/15 0:20, PG Bug reporting form = wrote:
The following = bug has been logged on the website:

Bug = reference:      15430
Logged by: =          Bart = Debersaques
Email address: =      agile.data.analytics@gmail.com
PostgreSQL = version: 11rc1
Operating system:   Centos 7
Description:        

[ ... ]

psql <<-EOF
explain
select *
from
part_test.measurement m1
inner join = part_test.measurement2 m2
on m1.city_id =3D m2.city_id and = m1.logdate =3D m2.logdate
where m1.logdate in = ('2006-02-01'::date, '2006-03-01'::date)
EOF
#  Hash Join =  (cost=3D66.97..170.25 rows=3D3 width=3D32)
# =   Hash Cond: ((m2.city_id =3D m1.city_id) AND (m2.logdate =3D = m1.logdate))
#   ->  Append =  (cost=3D0.00..75.50 rows=3D3700 width=3D16)
# =         ->  Seq Scan on = measurement2_y2006m02 m2  (cost=3D0.00..28.50
rows=3D18= 50 width=3D16)
# =         ->  Seq Scan on = measurement2_y2006m03 m2_1  (cost=3D0.00..28.50
rows=3D1850 width=3D16)
#   -> =  Hash  (cost=3D66.43..66.43 rows=3D36 width=3D16)
#         -> =  Append  (cost=3D0.00..66.43 rows=3D36 width=3D16)
# =             &n= bsp; ->  Seq Scan on measurement_y2006m02 m1 =  (cost=3D0.00..33.12
rows=3D18 width=3D16)
# =             &n= bsp;       Filter: (logdate =3D = ANY
('{2006-02-01,2006-03-01}'::date[]))
# =             &n= bsp; ->  Seq Scan on measurement_y2006m03 m1_1 =  (cost=3D0.00..33.12
rows=3D18 width=3D16)
# =             &n= bsp;       Filter: (logdate =3D = ANY
('{2006-02-01,2006-03-01}'::date[]))

# conclusion: join performed on full tab scans, join not = performed on a
per-partion basis

Have you changed the value of = enable_partitionwise_join parameter to 'on'?
It's 'off' = by default, so join is not performed on per-partition basis.

Thanks,
Amit


= --Apple-Mail=_06DB298F-83D6-4022-AE39-F431873B0810--