How to Reduce the Logical Reads, To Imporve the Performance of the Query
-
Upload
khalidmallick7258 -
Category
Documents
-
view
14 -
download
5
description
Transcript of How to Reduce the Logical Reads, To Imporve the Performance of the Query
8/26/2014 How to Reduce the Logical Reads, to imporve the Performance of the Query
http://www.sqlservercentral.com/Forums/Topic571160-8-1.aspx 1/5
Log in :: Register :: Not logged in Search Go
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Email address:
Stay up to date!
Was this topic useful? Register to stay up to date with the latest news, articles, scripts and forum posts.
Register
Subscribing to our newsletters getsyou:
ALL of our content (thousands ofarticles, scripts, and forum postings)A daily newsletter (example)A weekly news round up in ourDatabase Weekly newsletter(example)The opportunity to ask and answerquestions in our forumsA daily Question of the Day to testand help you increase yourknowledge of SQL Server.
Recent Posts Popular Topics Home Search Members Calendar Who's On
Home » SQL Server 7,2000 » T-SQL » How to Reduce the Logical Reads, to imporve...
12 posts, Page 1 of 2 1 2 »»
How to Reduce the Logical Reads, to imporve the Performance of the QueryRateTopic
DisplayMode
TopicOptions
Author Message
santoooo Posted Wednesday, September 17, 2008 10:29 AM
SSC Journeyman
Group: General ForumMembers Last Login: Wednesday,July 10, 2013 10:13 PM Points: 83, Visits: 253
Hi,
I heard abt the Logical/ Physical Reads In Sql Server.
Could any one please explain me
What are Logical Reads?What are Physical Reads?
and also heared, Less no of Logical Reads improves the Query performance.
please explain me how can we reduce the logical reads..?
Thanks,Santosh
Post #571160
David Benoit Posted Wednesday, September 17, 2008 10:47 AM
SSCrazy
From BOL
Logical reads - number of pages read from the data cachePhysical reads - number of pages read from disk
To reduce reads you need to look at a couple of things, first being query design,secondly being indexing. If your query is pulling a large number of records that could be
8/26/2014 How to Reduce the Logical Reads, to imporve the Performance of the Query
http://www.sqlservercentral.com/Forums/Topic571160-8-1.aspx 2/5
Group: General ForumMembers Last Login: Friday,August 22, 2014 12:19PM Points: 2,107, Visits:3,582
filtered by getting a smaller set prior to pulling that data then you can always cut downon reads that way. With improved indexing, specifically with covering indexes, you canreduce the number of pages that are being read as well.
All of this is just a basic guideline but should be applied to the analysis of all thequeries that are running in your production environment. A query like the following (notmine but got this from somewhere else so, no credit here) should help in getting thosequeries.
SELECT TOP 20SUBSTRING(qt.text, (qs.statement_start_offset/2)+1, ((CASE qs.statement_end_offsetWHEN -1 THEN DATALENGTH(qt.text)ELSE qs.statement_end_offsetEND - qs.statement_start_offset)/2)+1) AS SQLText, qs.execution_count, qs.total_logical_reads, qs.last_logical_reads, qs.min_logical_reads, qs.max_logical_reads, qs.total_elapsed_time, qs.last_elapsed_time, qs.min_elapsed_time, qs.max_elapsed_time, qs.last_execution_time, qp.query_planFROMsys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qtCROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qpWHEREqt.encrypted=0ORDER BYqs.last_logical_reads DESC
David
@SQLTentmaker
SQL Tentmaker
“He is no fool who gives what he cannot keep to gain that which he cannot lose” - JimElliot
Post #571183
santoooo Posted Wednesday, September 17, 2008 10:16 PM
SSC Journeyman
Group: General ForumMembers Last Login: Wednesday,July 10, 2013 10:13 PM Points: 83, Visits: 253
Hi,
Thank you for your valuable information.
So, to reduce the Logical Reads we need proper indexing for the tables.
Regards,Santosh
Post #571459
Sergiy Posted Wednesday, September 17, 2008 10:53 PM
SSCarpal Tunnel
Group: General ForumMembers Last Login: Monday,August 18, 2014 9:16PM Points: 4,576, Visits:8,347
santoooo (9/17/2008)
So, to reduce the Logical Reads we need proper indexing for the tables.
Regards,Santosh
No, you need proper database.Proper schema, proper data normalisation, proper data types, proper keys, properindexes, etc.
8/26/2014 How to Reduce the Logical Reads, to imporve the Performance of the Query
http://www.sqlservercentral.com/Forums/Topic571160-8-1.aspx 3/5
You need to open a good book about relational DB design and follw itsrecommendations.
Post #571473
papapumpy Posted Tuesday, January 5, 2010 3:04 PM
Forum Newbie
Group: General ForumMembers Last Login: Tuesday,January 5, 2010 3:20 PMPoints: 2, Visits: 1
Yes, indexing helps but reducing logical reads does not help performance. maybe a tinybit
read some article about buffer hit ratio and data cache. physical reads is the one takessignificantly longer time. i actually wrote my final term paper about that when i was inCS in my college long time ago.
Dr. Inner Join
Post #842453
GilaMonster Posted Tuesday, January 5, 2010 3:11 PM
SSC-Forever
Group: General ForumMembers Last Login: Today @2:51 PM Points: 42,784, Visits:35,895
You did notice that this thread is over a year old?
Gail ShawMicrosoft Certified Master: SQL Server 2008, MVPSQL In The Wild: Discussions on DB performance with occasional diversions intorecoverability
We walk in the dark places no others will enterWe stand on the bridge and no one may pass
Post #842458
papapumpy Posted Tuesday, January 5, 2010 3:21 PM
Forum Newbie
Group: General ForumMembers Last Login: Tuesday,January 5, 2010 3:20 PMPoints: 2, Visits: 1
LOL!
Post #842463
John Rowan Posted Tuesday, January 5, 2010 3:37 PM
Hall of Fame
Group: General ForumMembers Last Login: Tuesday,August 19, 2014 10:01AM Points: 3,844, Visits:3,841
papapumpy (1/5/2010)
Yes, indexing helps but reducing logical reads does not help performance. maybe atiny bit
read some article about buffer hit ratio and data cache. physical reads is the onetakes significantly longer time. i actually wrote my final term paper about that when iwas in CS in my college long time ago.
Dr. Inner Join
8/26/2014 How to Reduce the Logical Reads, to imporve the Performance of the Query
http://www.sqlservercentral.com/Forums/Topic571160-8-1.aspx 4/5
The thread may be over a year old, but I have to add a correction as to not confuse newreaders. Reducing logical reads [b]does[/do] improve query performance! In fact, logicalreads is one of the best metric to look at when optimizing a query. Logical readsrepresents the data that must be read from cache in order to process a query. The lessamount of data needed to process a query, the better it performs.
Using SET STATISTICS IO ON when optimizing queries can help you quickly, bylooking at the logical reads counter, determine where to focus your tuning efforts.Seeing the logical reads by object can quickly point you to poorly performing sectionsof your query.
So to recap, I think the statement that "reducing logical reads does not helpperformance. maybe a tiny bit" is not true.
John Rowan
============================================================================================================Forum Etiquette: How to post data/code on a forum to get the best help - byJeff Moden
Post #842470
santoooo Posted Wednesday, January 6, 2010 6:21 AM
SSC Journeyman
Group: General ForumMembers Last Login: Wednesday,July 10, 2013 10:13 PM Points: 83, Visits: 253
Dear All,
Thank you very much for your information.
Post #842715
Dinesh Babu
Verma Posted Wednesday, February 8, 2012 2:15 AM
Forum Newbie
Group: General ForumMembers Last Login: Tuesday,April 2, 2013 1:37 AM Points: 6, Visits: 83
Summary Info:
Logical Reads : Reading Data pages from CachePhysical Reads : Reading Data pages from Hard DiskBuffer Cach Hit Ratio logical reads – physical reads)/logical read * 100%
Details Info:
Logical Reads:Logical read indicates total number of data pages needed to be accessed from datacache to process query. It is very possible that logical read will access same datapages many times, so count of logical read value may be higher than actual number ofpages in a table. Usually the best way to reduce logical read is to apply correct index orto rewrite the query.
Physical Reads Physical read indicates total number of data pages that are read from disk. In case nodata in data cache, the physical read will be equal to number of logical read. Andusually it happens for first query request. And for subsequent same query request thenumber will be substantially decreased because the data pages have been in datacache.
Buffer Cash Hit RatioBuffer hit ratio will be calculated based on these two kinds of read as the followingformula: (logical reads – physical reads)/logical read * 100%. The high buffer hit ratio (ifpossible to near 100%) indicates good database performance on SQL Server level. So
8/26/2014 How to Reduce the Logical Reads, to imporve the Performance of the Query
http://www.sqlservercentral.com/Forums/Topic571160-8-1.aspx 5/5
use information from physical read and buffer hit ratio to measure performance in serverlevel and logical read to measure individual query level
Thanks,Dinesh Babu Verma
Post #1248790
« Prev Topic | Next Topic »
12 posts, Page 1 of 2 1 2 »»
Permissions
Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.