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 1fgZ0K-0001gO-LN for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Jul 2018 17:15:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fgZ0I-0007Ou-Tt for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Jul 2018 17:15:42 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgZ0I-0007On-Ny for pgsql-bugs@lists.postgresql.org; Fri, 20 Jul 2018 17:15:42 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgZ0G-0002jT-5z for pgsql-bugs@lists.postgresql.org; Fri, 20 Jul 2018 17:15:42 +0000 Received: from [192.168.127.1] (port=23848 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1fgZ0E-0006oO-2f; Fri, 20 Jul 2018 17:15:38 +0000 Received: from [127.0.0.1] (port=36556 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fgZ0D-000Lnq-2Y; Fri, 20 Jul 2018 17:15:37 +0000 From: Andrew Gierth To: Andres Freund Cc: ipluta@wp.pl, 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. In-Reply-To: <20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de> (Andres Freund's message of "Fri, 20 Jul 2018 09:39:45 -0700") Message-ID: <87in59j120.fsf@news-spur.riddles.org.uk> References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org> <20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 20 Jul 2018 18:15:36 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Andres" == Andres Freund 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)