Unanswered: why a 'fetch first 1 rows only' before view query ??
Hello DB2 friends. This new DBA is looking for some insight into why something is happening.
When I do an event monitor to troubleshoot slow execution of a query, I see that a fetch of the first row is occurring before the actual statment I'm trying to execute. I can't figure out why it's doing this. I'm sure performance improvements can be made to the view, but the fetch is what appears to be the performance hit.
Here's some background on what I'm doing:
I'm calling a function on a SQL Server 2005 database. A federated linked server is used to query a view on DB2 ("DB2 v220.127.116.11", "s070210", "MI00184", Fix Pack "2".) running on Linux ( 6 2 x86_64) as part of the function.
I checked and SQL Server using a trace and it doesn't appear to be doing anything that would cause the fetch.
I've attached a recap of the event monitor output and the event monitor output itself.
I figured out what was happening. The query from SQL Server to DB2 was written with 4 part notation rather than Open Query. This caused SQL Server to determine the execution plan for the DB2 statement rather than just sending the query natively to DB2. The 'fetch first 1 rows' was occuring in conjuction with a several other requests for information about how to format the query.