views:

62

answers:

1

I'm trying to use SQL Server Profiler (2005) to track down some application performance problems. One of the calls being made is to a table-valued user-defined function. This function wraps a select that joins several tables together.

In SQL Server Profiler, the call to the UDF is logged. However, the select that underlies the UDF isn't being logged at all. Because of this, I'm not getting useful data on which tables & indexes are being hit. I'd like to feed this info into the Database Tuning Advisor for some indexing advice.

Is there any way (short of unwrapping the queries themselves) to log the tables called by UDFs in Profiler?

+3  A: 

You can't: a multi-statement TVF is a black box and you can only get CPU, Read, Writes etc.

by "black box" I mean it's a fully encapsulated and opaque series of statements inside another query, and there is no "flow" like you'd get line by line through a stored proc.

An in-line TVF is expanded like a view or macro into the main query and can be seen.

Edit: related: Table Valued Function where did my query plan go?

gbn
That's what I suspected. :-\
Craig Walker
@Craig Walker: They are a pain to troubleshoot. Use them sparingly. For example, all rows must be returned from the TVF even if not all are needed, or when in other situations filters etc would be applied at more optimal points in the query
gbn
Hmm... converting the TVF into an inline TVF might be doable.
Craig Walker