Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Timeout and Query Performance

Tags:

c#

sql

sql-server

I have the following SQL query:

SELECT TOP(100)
    VIEW_RAUMBUCHUNG_RAUM.RAUMID,
    VIEW_RAUMBUCHUNG.VON,
    VIEW_RAUMBUCHUNG.BIS,
    VIEW_RAUMBUCHUNG.RAUMBEZEICHNUNG,
    VIEW_RAUMBUCHUNG.THEMA,
    VIEW_RAUMBUCHUNG.V_EMAIL,
    VIEW_RAUMBUCHUNG.VERANSTALTER,
    VIEW_RAUMBUCHUNG_RAUM.COLOR,
    VIEW_RAUMBUCHUNG.RAUMID AS Expr1,
    VIEW_RAUMBUCHUNG_RAUM.BEZEICHNUNG
FROM VIEW_RAUMBUCHUNG
RIGHT OUTER JOIN VIEW_RAUMBUCHUNG_RAUM ON VIEW_RAUMBUCHUNG.RAUMID = VIEW_RAUMBUCHUNG_RAUM.RAUMID

Is there a way to improve this? VIEW_RAUMBUCHUNG contains 27000 entries, and the performance is very slow, even if I limit results to the first 100 records. Or is there a way to optimize the SQL-Server?

My second problem is, if i try to load the whole 27000 entries, I get a timeout after 20 seconds, but I set the timeout in IIS to 120 seconds. Why is that and how can I avoid a timeout?

Thanks in advance.

like image 251
Paks Avatar asked Jul 14 '26 13:07

Paks


1 Answers

  1. Create Indexes on the RaumID fields in the two tables
  2. Create a view instead of joining the two tables
  3. Set your timeout to a larger values or to 0 which means it won't timeout
like image 165
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Avatar answered Jul 16 '26 03:07

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!