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?
SELECT max_oldmedicionid FROM OPENQUERY(LINKPDATL,'select max(oldmedicionid) max_oldmedicionid from PDATL.tl.tlinputtable')?SELECT oldmedicionid FROM tl.tlinputtable, then that entire result set is sent to the MS SQL Server, and the MS SQL Server is doing the aggregation. It's just poor optimization on the part of either SQL Server or the PostgreSQL provider.OPENQUERY()allows you to control exactly what the query being used is.