I’m seeing very poor query performance when running a stored routine on a MySQL linked server from a SQL Server. The query runs from the SQL Server
select * from OPENQUERY(COGNOS, 'call reporting.sr_vendor_location_report(''2011-06-13 00:00:00'',''2012-01-18 00:00:00'',1,''0,1'',28,''(All)'',''(All)'',1,''(All)'')')
takes 15 seconds but if I check the mysql query log or run it on the server directly, I see that it only takes 7 seconds.
I’ve read elsewhere that MySQL ODBC connections are slow but I haven’t seen any solutions suggested. I tried setting up mysql-proxy (just running it with a redirection – no LUA scripts) but didn’t see any improvement. I’m using the MySQL ODBC Connector 5.1 and running MySQL version 5.5 on the server.
I’d be enormously grateful for any ideas on what to try.
UPDATE
It turns out that openquery runs each query twice on the mysql server, the first time presumably to get metadata. Is there any way to avoid this?
It turns out that using RPC instead of OPENQUERY solves the problem of SQL Server generating two queries.
e.g.
becomes