0

Please, could you give me some tips for my problem with table valued function in SQL?

I am designing Windows Forms app in C#, Visual Studio and I am using Entity Framework to join SQL database.

I've already created number of table valued functions and most of them work fine, but a few of them don't.

They usually works OK, but from time to time it freezes when program starts to read data from SQL (using foreach). It shows exception that time expired (after maybe 30 seconds).

The strange thing is, that usually after PC restart table valued function starts to work OK for a while.

Please, do you have any suggests what to do with it?

I am using Microsoft sql server.

Thank you very much.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
Frantisek
  • 1
  • 1
  • 1
    [Why should I "tag my RDBMS"?](https://meta.stackoverflow.com/questions/388759/why-should-i-tag-my-rdbms) - please add a tag to specify whether you're using `mysql`, `postgresql`, `sql-server`, `oracle` or `db2` - or something else entirely. – marc_s Nov 26 '21 at 12:57
  • You can monitor performance with the SQL Server Query Store: https://learn.microsoft.com/en-us/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store?view=sql-server-ver15 – David Browne - Microsoft Nov 26 '21 at 16:32

1 Answers1

0

It seems like the problem is not on the server-side. Check out that: Set database timeout in Entity Framework

yildizyasin
  • 116
  • 4
  • Thanks, I will check it! Problem is, that if function works correctly, result is in a second. But from time to time function just frozes for a minute and then it throws thi error... – Frantisek Nov 26 '21 at 13:29
  • It may also depend on the server load. Is it a local server or an online server. The exception is not server dependent but the running time depends on the server load. – yildizyasin Nov 26 '21 at 14:15
  • It is local, so it should be OK. It works in sql query fine, problem is just from time to time and in entity framework. – Frantisek Nov 26 '21 at 15:15