pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Andres Freund <andres@anarazel.de>
Cc: ipluta@wp.pl
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote.
Date: Fri, 20 Jul 2018 18:15:36 +0100
Message-ID: <87in59j120.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de>
References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org>
	<20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de>

>>>>> "Andres" == Andres Freund <andres@anarazel.de> writes:

 >> the clause:
 >> WHERE date_trunc('day'::text, dt::timestamp without time zone) =
 >> 'yyyy-mm-dd' 
 >> does not get shipped to the foreign server.

 Andres> You're probably going to have a higher likelihood of getting
 Andres> the bug fixed quickly if you'd include a full reproducer.

On remote:

create table foreigntab (dt timestamp);
insert into foreigntab
  select timestamp '2000-01-01' + (random()*568036800)
         * interval '1 second'
    from generate_series(1,100000);
create index on foreigntab (date_trunc('day',dt));
analyze foreigntab;

On local:

-- create foreigntab as a foreign table or import the foreign schema
-- e.g.
create server foreigndb foreign data wrapper postgres_fdw
  options (dbname 'foreigndb');
create user mapping for postgres server foreigndb;
import foreign schema public from server foreigndb into public;

postgres=# explain analyze select * from foreigntab where date_trunc('day', dt) = '2018-07-20';
                                                   QUERY PLAN                                                    
-----------------------------------------------------------------------------------------------------------------
 Foreign Scan on foreigntab  (cost=100.00..199.60 rows=13 width=8) (actual time=637.399..637.399 rows=0 loops=1)
   Filter: (date_trunc('day'::text, dt) = '2018-07-20 00:00:00'::timestamp without time zone)
   Rows Removed by Filter: 100000

-- 
Andrew (irc:RhodiumToad)




view thread (11+ messages)  latest in thread

Message-ID: <87in59j120.fsf@news-spur.riddles.org.uk>
Permalink:  ../87in59j120.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87in59j120.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, andres@anarazel.de, ipluta@wp.pl
  Subject: Re: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote.
  In-Reply-To: <87in59j120.fsf@news-spur.riddles.org.uk>
  References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org> <20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de> <87in59j120.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox