Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

sys.fn_xe_file_target_read_file performance

$
0
0

Hi,

I am working with extended events and the function sys.fn_xe_file_target_read_file. I am using the file_name and file_offset to get new events, since the last time I queried the function. I am checking for new events once a minute like this:

exec sp_executesql N'SELECT @@SERVERNAME AS server_name, @session_name AS session_name, @collection_id AS collection_id, module_guid, package_guid, [object_name], event_data, [file_name], file_offset FROM sys.fn_xe_file_target_read_file(@file_path, NULL, @file_name, @file_offset)',N'@session_name nvarchar(13),@collection_id bigint,@file_path nvarchar(84),@file_name nvarchar(104),@file_offset bigint',@session_name=N'system_health',@collection_id=4127175,@file_path=N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\LOG\system_health*.xel',@file_name=N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\LOG\system_health_0_130317495005090000.xel',@file_offset=66560

I have started to get a problem on some servers that it is very slow, even when there are few new events. It can take up to 30 seconds to get one single event.

After some investigations I found out that it seems to be related to the number of files. I had configured the extended event target to 100 files of the size 5 MB. On the server where we have the problem there were 41 files. When I deleted all files but the latest, then the time went down to about 1 second. After stopping and starting the session and then deleting the old file (keeping only one small file), the time went down to about 50 ms.

So I am trying to figure out how sys.fn_xe_file_target_read_file works (what is it doing), and the pros and cons of having many files or large files. I will do some testing, but if anyone has any experiences to share it would be great.

The version number is 11.0.3373.0.

Best regards

Ola Hallengren
http://ola.hallengren.com




Viewing all articles
Browse latest Browse all 15264

Trending Articles