Why Logical Reads Are A Bad Metric For Query Tuning In SQL Server

  Рет қаралды 1,864

Erik Darling (Erik Darling Data)

Erik Darling (Erik Darling Data)

Күн бұрын

Пікірлер: 26
@mrancourt73
@mrancourt73 7 ай бұрын
Yes, using one sole metric for anything is just losing sight of the big picture. Thanks for the thoughts Erik and Kudos for your posts :)
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Hahaha, yep, that’s something a lot of people don’t take into consideration.
@gustavswanepoel9207
@gustavswanepoel9207 7 ай бұрын
Highly useful information. Thank you for sharing, Erik.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
My kindergarten teacher would be very happy with me, I suppose.
@ghauan
@ghauan 7 ай бұрын
Hope you and Brent still are on good terms 😉. Just saw his think like the engine for all times sake, and I pretty sure he was talking about using the logical reads. 3:19 (not finished with this video atm though)
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Oh I don’t know, I haven’t seen that material in quite a long time.
@ghauan
@ghauan 7 ай бұрын
But you have some good points in the video. But how can we control the physical reads? I think Brent said we could not control the physical reads mutch?
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
@@ghauan You can’t control what’s in the buffer pool (unless you’re constantly priming it with some queries), but you can control the size of the buffer pool (add memory), and how efficiently it’s used (query and index tuning). Again, if the workload is I/O bound, I’m looking for ways to fix that by finding queries that do a lot of physical reads.
@BrentOzarUnlimited
@BrentOzarUnlimited 7 ай бұрын
We are indeed on great terms! It's funny, now that I'm working more with Postgres, I'm starting to focus more on CPU time consumed, and it's making me question if logical reads is a good idea on SQL Server, too! Your cloud bills don't go down when logical reads go down.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
@@BrentOzarUnlimited *Aside from the $17 you still owe me from that time we went to Arby's.
@andreysamykin1143
@andreysamykin1143 7 ай бұрын
But if there's no corresponding data in the buffer, logical reads will cause physical reads in its turn. So, the more we read, the more data should be in the buffer (physical reads). What's your opinion on that?
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Exactly what I say in the video. When that happens you see physical reads. Fixing those is a good idea. If all you’re doing is logical reads, focus on CPU and duration.
@DanielMaenle
@DanielMaenle 7 ай бұрын
Would it make any sense to just cursory look at logical reads to see if those queries could benefit from a more optimal index which would reduce the amount it needs to do? Or modify the query to then get less data. Those are the only two reasons I have reviewed logical reads, but those queries also usually present themselves in other metrics as well.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Nah, CPU and duration usually tell a better story. Sure, logical reads may generally reduce as you tune things, but it’s not a reliable indicator that something is slow.
@mrfuzztone
@mrfuzztone 7 ай бұрын
People often add too many redundant indexes or too many include columns trying to reduce reads. That ends up causing competition for RAM. I have worked on systems where I reduced the space used by indexes by 50% and the system got faster. Yeah, probably more logical reads out of RAM. Actually, that is one of those things that keeps SQL Server performance people in business. A lot of people also make mistakes with queries that process a lot of rows. They think they need an extra index or more include columns (or worse, more key columns). They usually don't know what a bitmap filter can do.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Yep, getting rid of unused and overlapping indexes is huge for a lot of systems, especially when they have way too little memory for what they’re doing anyway.
@robj2118
@robj2118 7 ай бұрын
I guess my thinking was logical reads is something I can usually better control by query turning, index tuning, etc. And by reducing logical reads that would (could) in turn reduce physical reads.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Something you can better control than what?
@robj2118
@robj2118 7 ай бұрын
@@ErikDarlingData I can better control logical reads than physical reads as I can't predict what's cached. Also, it seems some of the queries CPU time versus duration were odd... seeming some queries were single threaded vs multi-threaded. I guess what I am saying how do I tune towards physical reads vs logical reads (w/o upgrading hardware)?
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
I think you're misunderstanding me a bit. I'm saying you should tune queries doing the most physical reads on average the same way you'd tune any other query, assuming that you're on an I/O bound server. Those ones need the most help from a workload perspective. Just make sure you're sampling queries from when users are most active.
@NakeDr
@NakeDr 7 ай бұрын
Thx!
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
You are very welcome!
@kevinfries55
@kevinfries55 7 ай бұрын
Tell me you’re not posing for the centerfold of BeerBelly Monthly.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Someday I’ll grace their hallowed pages.
@FlaggedStar
@FlaggedStar 7 ай бұрын
And then somebody mentions memory optimized tables and things get rather sad.
@ErikDarlingData
@ErikDarlingData 7 ай бұрын
Ha ha, not on this channel.
How To Use A Numbers Table To Replace WHILE Loops In SQL Server Functions
9:44
Erik Darling (Erik Darling Data)
Рет қаралды 1 М.
Performance Pains With NOT IN And NULLable Columns In SQL Server
12:36
Erik Darling (Erik Darling Data)
Рет қаралды 842
这是自救的好办法 #路飞#海贼王
00:43
路飞与唐舞桐
Рет қаралды 115 МЛН
Elza love to eat chiken🍗⚡ #dog #pets
00:17
ElzaDog
Рет қаралды 22 МЛН
Это было очень близко...
00:10
Аришнев
Рет қаралды 7 МЛН
СОБАКА ВЕРНУЛА ТАБАЛАПКИ😱#shorts
00:25
INNA SERG
Рет қаралды 2,7 МЛН
An Advanced SQL Server Query Profiling Technique
11:01
Erik Darling (Erik Darling Data)
Рет қаралды 2 М.
A Video For My Friend Brent About Automatic Tuning
10:35
Erik Darling (Erik Darling Data)
Рет қаралды 1 М.
Fundamentals of Vacuum in PostgreSQL: Module 1
12:06
Smart Postgres
Рет қаралды 1,1 М.
Everything You Know About Isolation Levels Is Wrong Promo
8:38
Erik Darling (Erik Darling Data)
Рет қаралды 738
Choosing Between Triggers And Foreign Keys In SQL Server
13:29
Erik Darling (Erik Darling Data)
Рет қаралды 576
Advanced String Searching In SQL Server
14:31
Erik Darling (Erik Darling Data)
Рет қаралды 1,1 М.
Why You Should Always Use Unicode For Dynamic SQL
10:19
Erik Darling (Erik Darling Data)
Рет қаралды 733
A Little About Paging Queries And Batch Mode In SQL Server
19:45
Erik Darling (Erik Darling Data)
Рет қаралды 1 М.
When Profiling SQL Server Stored Procedures Gets Tricky
10:36
Erik Darling (Erik Darling Data)
Рет қаралды 351
Tricky Scalar UDF Rewrites In SQL Server
9:35
Erik Darling (Erik Darling Data)
Рет қаралды 467
这是自救的好办法 #路飞#海贼王
00:43
路飞与唐舞桐
Рет қаралды 115 МЛН