Re: Postgresql 14/15/16/17 partition pruning on dependent table during join

2024-11-04 Thread Andrei Lepikhov
On 4/11/2024 15:23, Stepan Yankevych wrote: Let's classify it as possible improvement / new feature for further releases. Optimizer definitely should be able to add that extra (redundant) condition *and e.exec_date_id >= 20241021* or even transform* e.exec_date_id >= co.create_date_id * to

Re: Postgresql 14/15/16/17 partition pruning on dependent table during join

2024-11-04 Thread Stepan Yankevych
1021 Stepan Yankevych From: Andrei Lepikhov Sent: Sunday, November 3, 2024 4:42 AM To: Vijaykumar Jain ; Stepan Yankevych Cc: pgsql-performance@lists.postgresql.org Subject: Re: Postgresql 14/15/16/17 partition pruning on dependent table during join On 3

Re: Postgresql 14/15/16/17 partition pruning on dependent table during join

2024-11-02 Thread Andrei Lepikhov
On 3/11/2024 03:21, Vijaykumar Jain wrote: On Fri, 1 Nov 2024 at 18:51, Stepan Yankevych wrote: Partition pruning is not pushing predicate into dependent table during join in some cases. See example. Predicate highlighted in red i think your observation is correct. you may need to provide

Re: Postgresql 14/15/16/17 partition pruning on dependent table during join

2024-11-02 Thread Vijaykumar Jain
On Fri, 1 Nov 2024 at 18:51, Stepan Yankevych wrote: > > Partition pruning is not pushing predicate into dependent table during join > in some cases. > See example. Predicate highlighted in red > i think your observation is correct. you may need to provide redundant predicate

Postgresql 14/15/16/17 partition pruning on dependent table during join

2024-11-01 Thread Stepan Yankevych
Partition pruning is not pushing predicate into dependent table during join in some cases. See example. Predicate highlighted in red explain select * from public.orders co left join public.execution e on e.order_id = co.order_id and e.exec_date_id >= co.create_date_id where co.order_text

Re: Partition pruning with array-contains check and current_setting function

2024-09-11 Thread Marcelo Zabani
Aggregate -> Seq Scan on tbl1 tbl Filter: (tenant_id = ANY ('{1}'::integer[])) Sadly I can't make tenants() immutable because it's a runtime setting, and making tenants() STABLE does not lead to partition pruning with or without the

Partition pruning with array-contains check and current_setting function

2024-08-07 Thread Marcelo Zabani
US 2, REMAINDER 0);CREATE TABLE tbl2 PARTITION OF tbl FOR VALUES WITH (MODULUS 2, REMAINDER 1);INSERT INTO tbl (tenant_id, some_col) SELECT 1, * FROM generate_series(1,1);INSERT INTO tbl (tenant_id, some_col) SELECT 3, * FROM generate_series(1,10000);* Partition pruning works as expected for

Re: Is partition pruning impacted by data type

2024-03-04 Thread sud
at can be accommodated easily with a >> "timestamp" data type. >> >> However the question we have is , >> *1)If there is any downside of having the partition key with "timestamp >> with timezone" type? Will it impact the partition pruning of the queri

RE: partition pruning only works for select but update

2022-07-01 Thread James Pang (chaolpan)
l-performance@lists.postgresql.org Subject: Re: partition pruning only works for select but update Justin Pryzby writes: > On Fri, Jul 01, 2022 at 08:30:40AM +, James Pang (chaolpan) wrote: >> We have other application depend on V13, possible to backport code >> changes to V13 as >> ht

Re: partition pruning only works for select but update

2022-07-01 Thread Tom Lane
Justin Pryzby writes: > On Fri, Jul 01, 2022 at 08:30:40AM +, James Pang (chaolpan) wrote: >> We have other application depend on V13, possible to backport code changes >> to V13 as >> https://git.postgresql.org/gitweb/?p=postgresql.git;a=patch;h=86dc90056dfdbd9d1b891718d2e5614e3e432f35 > I

Re: partition pruning only works for select but update

2022-07-01 Thread Justin Pryzby
> Sent: Tuesday, June 28, 2022 9:30 PM > To: James Pang (chaolpan) > Cc: pgsql-performance@lists.postgresql.org > Subject: Re: partition pruning only works for select but update > > "James Pang (chaolpan)" writes: > > But when > > Explain update tab

RE: partition pruning only works for select but update

2022-07-01 Thread James Pang (chaolpan)
Pang (chaolpan) Cc: pgsql-performance@lists.postgresql.org Subject: Re: partition pruning only works for select but update "James Pang (chaolpan)" writes: > But when > Explain update table set .. where partitionkey between to_timestamp() and > to_timestamp(); >

RE: partition pruning only works for select but update

2022-06-28 Thread James Pang (chaolpan)
For release v14, optimizer can handle large partition counts query ( select ,update ,delete) and partition pruning is similar as SELECT, right? We will check option to upgrade to v14. Thanks, James -Original Message- From: Tom Lane Sent: Tuesday, June 28, 2022 9:30 PM To: James

Re: partition pruning only works for select but update

2022-06-28 Thread Tom Lane
"James Pang (chaolpan)" writes: > But when > Explain update table set .. where partitionkey between to_timestamp() and > to_timestamp(); > It still show all of partitions with update ... In releases before v14, partition pruning is far stupider for UPDATE (and DELETE)

partition pruning only works for select but update

2022-06-28 Thread James Pang (chaolpan)
Hi, We have a table have range partition (about 5K partitions) , when Explain select count(*) from table where partitionkey between to_timestamp() and to_timestamp(); It show Aggregate (cost=15594.72..15594.73 rows=1 width=8) -> Append (cost=0.15..15582.00 rows=5088 width=0) Sub

RE: Partition pruning with joins

2020-11-04 Thread Ehrenreich, Sigrid
e this is understandable, English is not my native language 😉). Regards, Sigrid -Original Message- From: David Rowley Sent: Wednesday, November 4, 2020 9:13 PM To: Ehrenreich, Sigrid Cc: pgsql-performance@lists.postgresql.org Subject: Re: Partition pruning with joins On Wed, 4 Nov 2

Re: Partition pruning with joins

2020-11-04 Thread David Rowley
51 width=4) > Filter: ((part_key >= 110) AND (part_key <= 160)) > > > I know, that I could get rid of this problem, by rewriting the query to > include the partitioned table in the where clause like this: > WHERE fact.part_key >= 210 and fact.part_key <=

RE: Partition pruning with joins

2020-11-04 Thread Ehrenreich, Sigrid
PM To: Ehrenreich, Sigrid ; pgsql-performance@lists.postgresql.org Subject: Re: Partition pruning with joins On Tue, 2020-11-03 at 13:20 +, Ehrenreich, Sigrid wrote: > I would like to join a partitioned table and have the joined columns in the > where clause to be used for partition p

Re: Partition pruning with joins

2020-11-03 Thread Laurenz Albe
On Tue, 2020-11-03 at 13:20 +, Ehrenreich, Sigrid wrote: > I would like to join a partitioned table and have the joined columns in the > where clause to be used for partition pruning. > From some readings in the internet, I conclude that this was not possible in > v12. I h

Partition pruning with joins

2020-11-03 Thread Ehrenreich, Sigrid
Hi, I would like to join a partitioned table and have the joined columns in the where clause to be used for partition pruning. From some readings in the internet, I conclude that this was not possible in v12. I hoped for the “improvements in partition pruning” in v13, but it seems to me, that

Re: Partition Pruning (Hash Partitions) Support for DELETEs in PostgreSQL 11 and 12

2020-03-23 Thread Ronnie S
Thanks! On Mon, Mar 23, 2020 at 12:10 AM Justin Pryzby wrote: > On Sun, Mar 22, 2020 at 11:45:53PM -0400, Ronnie S wrote: > > Hello All, > > > > While doing some tests with hash partitioning behavior in PG11 and 12, I > > have found that PG11 is not performing par

Re: Partition Pruning (Hash Partitions) Support for DELETEs in PostgreSQL 11 and 12

2020-03-22 Thread Justin Pryzby
On Sun, Mar 22, 2020 at 11:45:53PM -0400, Ronnie S wrote: > Hello All, > > While doing some tests with hash partitioning behavior in PG11 and 12, I > have found that PG11 is not performing partition pruning with DELETEs > (explain analyze returned >2000 lines). I then ran the

Partition Pruning (Hash Partitions) Support for DELETEs in PostgreSQL 11 and 12

2020-03-22 Thread Ronnie S
Hello All, While doing some tests with hash partitioning behavior in PG11 and 12, I have found that PG11 is not performing partition pruning with DELETEs (explain analyze returned >2000 lines). I then ran the same test in PG12 and recreated the objects using the same DDL, and it worked Here

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-13 Thread Sverre Boschman
oo.foo_id > where foo.foo_name = 'eeny' > > I do see an "Index Only Scan (never executed)" in the plan for the > irrelevant partitions: > > https://explain.depesz.com/s/AqlE > > However once I run "analyze foo_bar_baz" (or "vacuum a

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-05 Thread Thomas Kellerer
Tom Lane schrieb am 03.08.2019 um 18:05: > Yeah, I get the same plan with or without ANALYZE, too. In this example, > having the ANALYZE stats barely moves the rowcount estimates for > foo_bar_baz at all, so it's not surprising that the plan doesn't change. > (I do wonder how Thomas got a differen

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-03 Thread MichaelDBA
I too got the same plan (non runtime partition pruning plan) with or without the statistics.  So it looks like the workaround until this is fixed is to re-arrange the query to do a subselect to force the runtime partition pruning as Andreas suggested, which I tested and indeed does work for me

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-03 Thread Tom Lane
Andreas Kretschmer writes: > Am 03.08.19 um 16:06 schrieb Thomas Kellerer: >> But I'm more confused (or concerned) by the fact that the (original) >> query works correctly *without* statistics. > can't reproduce that :-( (PG 11.4 Community) Yeah, I get the same plan with or without ANALYZE, to

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-03 Thread Andreas Kretschmer
Am 03.08.19 um 16:06 schrieb Thomas Kellerer: it's posible to rewrite the query to: test=# explain analyse select count(*) from foo_bar_baz as fbb where foo_id = (select foo_id from foo where foo_name = 'eeny'); I know, that's not a solution, but a workaround. :-( Yes, I discovered that

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-03 Thread Thomas Kellerer
it's posible to rewrite the query to: test=# explain analyse select count(*) from foo_bar_baz as fbb where foo_id = (select foo_id from foo where foo_name = 'eeny'); I know, that's not a solution, but a workaround. :-( Yes, I discovered that as well. But I'm more confused (or concerned) by

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-03 Thread Andreas Kretschmer
Hi, Am 03.08.19 um 15:16 schrieb MichaelDBA: I too am a bit perplexed by why runtime partition pruning does not seem to work with this example.  Anybody got any ideas of this? please don't top-posting. it's posible to rewrite the query to: test=# explain analyse select cou

Re: Strange runtime partition pruning behaviour with 11.4

2019-08-03 Thread MichaelDBA
I too am a bit perplexed by why runtime partition pruning does not seem to work with this example.  Anybody got any ideas of this? Regards, Michael Vitale Thomas Kellerer wrote on 8/2/2019 9:58 AM: I stumbled across this question on SO: https://stackoverflow.com/questions/56517852

Strange runtime partition pruning behaviour with 11.4

2019-08-02 Thread Thomas Kellerer
Only Scan (never executed)" in the plan for the irrelevant partitions: https://explain.depesz.com/s/AqlE However once I run "analyze foo_bar_baz" (or "vacuum analyze"), Postgres chooses to do a "Parallel Seq Scan" for each partition: https://explain.de

Re: partition pruning

2019-02-14 Thread suganthi Sekar
HI , Ok thanks. Regards, Suganthi Sekar From: Laurenz Albe Sent: 14 February 2019 18:07:49 To: suganthi Sekar; pgsql-performance@lists.postgresql.org Subject: Re: partition pruning suganthi Sekar wrote: > i am using Postgresql 11, i have 2 partition ta

Re: partition pruning

2019-02-14 Thread Justin Pryzby
On Thu, Feb 14, 2019 at 01:37:49PM +0100, Laurenz Albe wrote: > There is no condition on the table "call_report2" in your query, > so it is not surprising that all partitions are scanned, right? Some people find it surprising, since: a.call_id=b.call_id suganthi Sekar wrote: > > explain analyze >

Re: partition pruning

2019-02-14 Thread Laurenz Albe
suganthi Sekar wrote: > i am using Postgresql 11, i have 2 partition table , when i joined both > table in query > a table its goes exact partition table , but other table scan all partition > > please clarify on this . > > i have enabled below parameter on in configuration file > Note : a