Reputation: 1483
i have this problem:
Making queries over linked server to postgresql is very slow, very, very slow, for example:
if i run in pgAdmin this query:
select max(oldmedicionid) from tl.tlinputtable
it returns the max result in just: 246 msec
But if i run that over linked server (using sqlserver 2008), i create the dblink using an odbc to postgresql, so if i run this:
select MAX(oldmedicionid) from LINKPDATL.PDATL.tl.tlinputtable
the query give me result in 1 minute or more sometimes...
What could be my problema?, i think is not with my postgresql database, is something like the dblink is very slow,
How can i improve the performance?
Upvotes: 1
Views: 2252
Reputation: 2483
Identification: There are good chances that the aggregation MAX(x
) in the ODBC
method is being done at the client side (not at the server side). This can easily be cross-checked by seeing that doubling the row-count would approximately double the Query time as well.
Resolution: If this is among a few corner cases, you could create a VIEW
that computes this on the Postgres server-side, and the ODBC
pick the aggregated value.
Upvotes: 4