1

Situation 1

Table 'lead_transaction'. Scan count 10, logical reads 394, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. Table 'appt_master'. Scan count 20, logical reads 4532, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 

Situation 2

Table 'lead_transaction'. Scan count 36466, logical reads 117088, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. Table 'appt_master'. Scan count 36466, logical reads 195492, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 

In Situation 1 Query is executing in 4 seconds, Used Left join

&

In Situation 2 Query is executing in 3 seconds, Used outer apply ,but Logical reads are very high.

So what is good as per performance?

3
  • 1) What are the CPU stats? 2) Show us the actual queries, 3) Post the Query Plans (Actual) Commented Mar 28, 2014 at 22:27
  • Yes sure. give me some time Commented Mar 29, 2014 at 6:54
  • Because there is only 1 second difference in performance, I am wondering whether the second query performed better due to the data being in the cache already. Have you tried flushing the cache and then seeing the performance of the queries. Commented Mar 31, 2014 at 13:29

1 Answer 1

1
+50

Since Logical Reads are from the data cache (memory) I would think the fact that there is a lot of reads will make little difference and it would seem that the second query is more efficient when reading a lot of data in small chunks while the first query reads the data in large chunks.

Id be interested to see how the performance would work if it was making physical reads and not logical reads.

Try clearing the buffers and execution plans before running each query and see what the performance is like.

•DBCC DROPCLEANBUFFERS clears buffer pool •DBCC FLUSHPROCINDB clears execution plans for that database 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for ans, but I am still not clear, which query is better?
If I execute these commands on my productions sever, will it heart anything?
It wont "hurt" anything but it will cause ALL queries to run slower until the buffers and caches are built again. Depending on how busy your LIVE instance is you might not want to run it on LIVE. I would suggest you research these two functions and make your own decision to run it or not.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.