Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
i have written a program that each 10 seconds hit a query in sql server 2012 db and than refresh a graphic page; this page is function of a single record from 4 different table in the database.

The db has set his maximum size as 1024 MB, while his minimum size is 0.
The db save a row each minutes, than in just 1 Month there are over 50.000 record each table, so the growing memory consumption (observed by Windows perfomance meter) raise the maximum size.

When the maximum has achieved, a later query (just a record) selected from these 4 table, takes about 15 seconds and the UI looks like freezed.
I have observed that instead a single record asked, SQL returns the entire table; i think cause it is cached...

Any suggestion to improve the speed?

Thanks

What I have tried:

DBCC... buffer clean... eccetera
Posted
Comments
ZurdoDev 12-Feb-16 15:31pm    
Indexing.
Member 11727760 12-Feb-16 16:07pm    
I think is not a query problem, i use the where clause with a single field named 'key' that is a string formatted with the date info and minutes details.
This field is also indexed.

I hope there is an unknown configuration option of SQL server, because this delay happened when the used memory raise the maximum size limit.
Sascha Lefèvre 12-Feb-16 15:33pm    
"I have observed that instead a single record asked, SQL returns the entire table"

How did you tell SQL Server to return a single record? Maybe show your SQL query here.
Member 11727760 15-Feb-16 8:34am    
"SELECT * FROM [Temperatures] WHERE IdMachine = " & Id & " AND Key= '" & Key& "'"
Sascha Lefèvre 15-Feb-16 9:10am    
You don't explicitly tell SQL Server here that it should return only a single record. If your constraints (IdMachine and Key) match more than one record, all matching records will be returned. To explicitly restrict the result to one record you could use the TOP-clause:
SELECT TOP 1 * FROM ...

1 solution

1 - Make sure that your query is optimized, for example avoid SELECT * you should individually include the specific columns that you need.

2 - Analyse query Execution Plan

3 - Profile your database on SQL Tuning mode and try to use Database Engine Tuning Advisor

4 - If is possible increase memory that SQL can use
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900