I have a PostgreSQL 9.6 server connecting to remote 9.3 server.
I'm trying to create the following materialized view :
CREATE MATERIALIZED VIEW test AS
SELECT id
FROM remote.logs
WHERE remote.logs.created_at > (now() - interval '1 day')
It's slow because the filtering is done on local server.
Here is the EXPLAIN ANALYSE result :
Foreign Scan on integration.logs (cost=100.00..219.69 rows=975 width=4)
Output: id
Filter: (logs.created_at > (now() - '1 day'::interval))
Remote SQL: SELECT id, created_at FROM public.logs
How to make condition filtering on the remote server ?
Note : remote filtering is working with such a query :
CREATE MATERIALIZED VIEW test AS
SELECT id
FROM integration.logs
WHERE integration.logs.created_at > (timestamp 'now()' - interval'1 day')
Foreign Scan on integration.logs (cost=100.00..166.06 rows=975 width=4)
Output: id
Remote SQL: SELECT id FROM public.logs WHERE ((created_at > '2017-05-31 11:44:10.89017'::timestamp without time zone))
But with this, each time I refreh the view, the date has already been calculated and stay for example above at 2017-05-31 11:44:10.89017
Any ideas ?
Thanks and regards