Re: Performance killed with FDW when using CAST.

2019-04-17 Thread Jorge Torralba
Funny that you mentioned that. I created the view a couple of hours ago and that resolve the problem. The view had the order by on the timestamp as well so it does not have to send the data over for sorting. I wish there was a way for postgres to allow control of what happens on which server when u

Re: Performance killed with FDW when using CAST.

2019-04-17 Thread Greg Spiegelberg
Hi Jorge, Can you create a view in the source database such as CREATE VIEW xxx_id_attributes AS SELECT id, CAST(attributes->>'account_incident_id' AS integer) FROM xxx WHERE attributes->'account_incident_id' ~ '^[0-9]+$'; On the remote server, create a foreign table on the new view and perform

Re: Performance killed with FDW when using CAST.

2019-04-17 Thread Jorge Torralba
I made a copy of the table and altered the column from hstore to jsonb. Ran the following query with the same performance issues. SELECT id, attributes FROM xxx WHERE account_id = 1 AND timestamp >= '2019-01-16 22:34:28.584' AND CAST(attributes ->> 'account_incident_id' as integer) = 2617116 or

Re: Performance killed with FDW when using CAST.

2019-04-16 Thread Jorge Torralba
I tried without casting and still the same problem on the server accessing remote data. On the server hosting the data, even with casting the query executes in 78ms. fty, I have run analyze on both the servers as well. Thanks JT On Tue, Apr 16, 2019 at 8:00 PM Ron wrote: > > > On 4/16/19 9:4