Recently I was able to go through Brent Ozar's "How to think like the SQL Server" free fundamental course and have to say content is very good.
Actually I have listen to the same course on YouTube several times. But this is the first time I have gone through it properly with Pen and Paper on my hand.
Learned few interesting things and one of the thing struck me most is on ever popular topic on scan and seek on SQL Server.
As per Brent,
SCAN -> is where SQL Server start reading object (table) from one end. This can be from top/beginning or bottom/end.
SEEK -> is where SQL Server start reading the object (table) from specific point.
Generally when we say table scan, we think SQL server reads the whole table, but in reality it can be different. For example query like below:
SELECT TOP 10 * FROM dbo.Users
This will only read top 10 rows from the table, but it is a scan.
On the other hand seek can read the entire table. For example if we give SQL server to seek for a value which is not in the table, it will seek from the start or end and will go through entire table to find it.
Amazing isn't it.
More details from Brent's site -> https://www.brentozar.com/archive/2019/10/how-to-think-like-the-sql-server-engine-so-index-seeks-are-great-right/
No comments:
Post a Comment