Solved

TSF_user procedure locking up database via Indicium

  • 1 May 2023
  • 4 replies
  • 110 views

Userlevel 4
Badge +13

We have lots of SQL sessions containing the tsf_user procedure taking up lots of CPU time. This only happens when tsf_user is called via Indicium. We can't really put the finger on why this is happening. What could be the cause? Today this even caused SQL server to lock up entirely.

CPU time total and per session:

 

icon

Best answer by Anne Buit 1 May 2023, 20:27

View original

This topic has been closed for comments

4 replies

Userlevel 7
Badge +5

Hi Roland,

What query are you using to obtain the command text from these sessions?

Indicium has no reason to call tsf_user() by itself on an end product database. This should always occur in context of another select query (prefilter/expression) or logic execution like a task or a process procedure.

Can you verify that the tsf_user() function on your database is schemabound?

Userlevel 4
Badge +13

Hi Anne,

I've attached the query.

The tsf_user() function is called in various prefilters, default procedures and tasks throughout the application.

I'm not sure about the function being schemabound or how to accomplish that. We're seeing major performance hits with this function when running the application in the Windows GUI via Indicium which doesn't happen when we use the Windows GUI directly on SQL Server. Unfortunately it's beyond my expertise to thoroughly debug Indicium sessions.

Userlevel 7
Badge +5

First of all, it is worth noting that the column command text in this query is not showing the command initiated by Indicium, but is constructed based on the object currently being executed.

It can be difficult to trace this problem to the actual command. There is, to my knowledge, not something like a 'stack trace’ that you can retrieve in which context the function is being called using dynamic management views.

The only way to find the query that's repeatedly calling tsf_user() and consuming all this CPU is by using the Query Store (I'm sure they'll show up in the Top Resource Consuming Queries) or really dive deep with the SQL Profiler / Extended Events.

Alternatively, you could perhaps consider altering the tsf_user() function to be inlineable. I'm pretty sure this will cause the ‘outer’ request not to make a separate query plan and request for the tsf_user() function. This requires at least SQL Server version 2019. Depending on the version of the Software Factory you are using, this would mean replacing with schemabinding with with inline = on in the function header code.

Userlevel 4
Badge +13

Those are definitely some valuable tips. Since we're running SQL Server 2019 I started with the last one and altered the function with the “inline = on” option. The function still works. I'll keep monitoring the performance and indeed also use the SQL Server profiler in SSMS. I had just completely forgotten about that tool's existence.