Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-04 Thread Tom Lane
=?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: > Does that mean that *any* expression containing text constants is not going > to be pushed down?? > That would be a really serious issues I’d say. If it contains text constants and not text variables, possibly so. Keep in mind though that this rule

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-04 Thread Michał Kłeczek
Hi All, > On 3 Mar 2024, at 10:34, Michał Kłeczek wrote: > > Hi, > > I have the following foreign table: > > CREATE FOREIGN TABLE t1 ( > grouping_column text, > date_column date, > whatever_data int > ); > > The query is: > > SELECT > sum(whatever_data) > FROM > t1 > GROUP BY > groupin

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Michał Kłeczek
> On 4 Mar 2024, at 07:46, Michał Kłeczek wrote: > > > >> On 3 Mar 2024, at 18:42, Tom Lane wrote: >> >> =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: >>> I’ve performed some more tests and it seems expressions with “extract” >>> function are not pushed down at all - >> >> Yeah :-(. I t

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Michał Kłeczek
> On 3 Mar 2024, at 18:42, Tom Lane wrote: > > =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: >> I’ve performed some more tests and it seems expressions with “extract” >> function are not pushed down at all - > > Yeah :-(. I traced through this, and it seems it's a collation > problem. Inte

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Michał Kłeczek
Ok, so that means the workaround is to create an extension with year(date) and month(date) functions that internally would call extract. Not ideal but workable I guess. — Michał > On 3 Mar 2024, at 18:42, Tom Lane wrote: > > =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: >> I’ve performed so

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Tom Lane
=?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: > I’ve performed some more tests and it seems expressions with “extract” > function are not pushed down at all - Yeah :-(. I traced through this, and it seems it's a collation problem. Internally, that call looks like extract('year'::text, d

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Michał Kłeczek
Thanks for help. >> I’ve performed some more tests and it seems expressions with “extract” >> function are not pushed down at all - >> the WHERE criteria from the following query are not pushed down as well and >> filter is performed locally: >> SELECT >> * >> FROM >> t1 >> WHERE extract(YEA

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Adrian Klaver
On 3/3/24 05:16, Michał Kłeczek wrote: On 3 Mar 2024, at 10:34, Michał Kłeczek wrote: Hi, I have the following foreign table: CREATE FOREIGN TABLE t1 ( grouping_column text, date_column date, whatever_data int ); The query is: SELECT sum(whatever_data) FROM t1 GROUP BY groupi

Re: postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Michał Kłeczek
> On 3 Mar 2024, at 10:34, Michał Kłeczek wrote: > > Hi, > > I have the following foreign table: > > CREATE FOREIGN TABLE t1 ( > grouping_column text, > date_column date, > whatever_data int > ); > > The query is: > > SELECT > sum(whatever_data) > FROM > t1 > GROUP BY > grouping_colu

postgres_fdw aggregate pushdown for group by with expressions

2024-03-03 Thread Michał Kłeczek
Hi, I have the following foreign table: CREATE FOREIGN TABLE t1 ( grouping_column text, date_column date, whatever_data int ); The query is: SELECT sum(whatever_data) FROM t1 GROUP BY grouping_colulmn, extract(YEAR FROM date_column), extract(MONTH FROM date_column); From my (preli