Тёмный

Understand Statistics in SQL Server for better performance troubleshooting 

Подписаться
Просмотров 376
% 21

Let us quickly learn about statistics in this session.
📚 ►Recommended sessions:
1. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-aJNSy94tsxM.html
2. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-7oMXxxp-kz4.html
📚 ►Full course on Troubleshooting CPU Spike in SQL Server: ru-vid.com/group/PLxuuX6jGq7kmDoqafhow70kQH2l8Z_Xm0&si=lIrrZo_cqj-YYQBy
🧑‍💼►Follow me on LinkedIn - www.linkedin.com/in/bobirmirzo-arslanov-548960173
Watch all my playlists here:
🚀►Full course on Troubleshooting sessions: ru-vid.com/group/PLxuuX6jGq7kmlUblaWyfIh-iT5r0EWrJX&si=gC5FAhH9i6_b0waY
🚀►Full course on Encrypting connections to SQL Server- ru-vid.com/group/PLxuuX6jGq7kmqOCqYa1lFxQOKFgTfb8j8&si=bBwHhLsu6m5CjFft
🚀 ►SQL Server replication session: ru-vid.com/group/PLxuuX6jGq7km5E54qm0zc7REGXw6WD4C8&si=fQ_PVoGQ1S8SeI6X
🚀 ►SQL Server Always On Availability Group: ru-vid.com/group/PLxuuX6jGq7klnjr9OIGt8R1SN76pQzuEB&si=zZVr_sJnc7I9H8d3
🚀 ► SQL Server internals: ru-vid.com/group/PLxuuX6jGq7kk5_OkxbZ8QDZ2HFBDy2XZ2&si=U2rRfgS2y87t5SU4
🚀 ► Course in On-memory OLTP: ru-vid.com/group/PLxuuX6jGq7kmt6gfHUW5KhfXGaoSiDXOB&si=fVS1s2L6If36Zg-r

Опубликовано:

 

9 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 13   
@Toan.nguyen17
@Toan.nguyen17 28 дней назад
Thank you for your content. I'm exploring mssql internal to preparing some interview about database dev. Blessed to view this
@arslanov1886
@arslanov1886 26 дней назад
Glad it was helpful!
@amarcse06
@amarcse06 11 дней назад
Very well explained 👏 .. Can you do a video on using sp_blitzcache and sp_blitzindex...It would be helpful for suggestions...or any kind of tools which will make our day so easy.
@arslanov1886
@arslanov1886 7 дней назад
Sure. I will work on this. This is interesting for me! Thank you.
@iNtellectual.paradoX
@iNtellectual.paradoX 10 дней назад
That is a perfect Explanation and on point. Bro I want you to create few Query optimization-related videos. If possible please create videos to understand the Execution plan and other query performance tweaks. Will wait for your new videos as you are on top of my list for MSSQL :). So informative.. Keep it up !
@arslanov1886
@arslanov1886 7 дней назад
Sure, will do. I have a plan on this and started working on it :)
@iNtellectual.paradoX
@iNtellectual.paradoX 7 дней назад
@@arslanov1886 :: Appreciate your hard work bro :) Thank you !
@iliashterev38
@iliashterev38 7 дней назад
Hello, Thank you and greetings from Bulgaria. Great tutorial. I would like to ask you - you say we can request bigger sample. Yet it is said that statistics is restricted to one 8K page. So it seems that we can not extend indefinitely. Or am I wrong in some way ?? Also - you mentioned that statistics can be created on a column without an index. Very few people mention that. So I am now exploring - if we can have just statistics to help us build a query plan, why do we need index/es ?? They are bulky etc. And most important they rely underneath on ... statistics. So seem like that they are like middle man. Would you like to help me (and the others) on that ?? Thank you.
@arslanov1886
@arslanov1886 7 дней назад
I do not think statistics is restricted to one 8K page as they are BLOBs learn.microsoft.com/en-us/sql/relational-databases/statistics/statistics?view=sql-server-ver16#statistics-1 Regarding difference, I highly recommend watching my video from 6:56 specifically as I explained how statistics help to choose best way to run the query. Let me explain in this way: You have following indexes: Index A Index B Index C You are starting to run a query to retrieve RowsA. In this case, what SQL Server does firstly is, to find the best( less-costly) way of getting these rows. For this, it should evaluate several options like below: 1. Run query with Index A (e.g. in this case SQL Server has to go through only 100 rows to retrieve RowsA) 2. Run query with Index B (e.g. in this case SQL Server has to go through only 120 rows to retrieve RowsA) 3. Run query with Index C (e.g. in this case SQL Server has to go through only 160 rows to retrieve RowsA) 4. Run query without any index (e.g. in this case SQL Server has to go through all 1000000 rows to retrieve RowsA) As can be seen, SQL Server chooses first option with Index A as it is less costly (it should work with less rows in this case). In this case, statistics help SQL Server to predict how many rows are expected to go through beforehand to choose the best option which is 100 rows in our first case. As you can see, if we take index as a route to reach destination, statistics is "prediction of costs" if we choose this specific route in terms of number of rows.
@arslanov1886
@arslanov1886 7 дней назад
Btw, Greetings from Japan!
@iliashterev38
@iliashterev38 7 дней назад
@@arslanov1886 Thank you for taking so much time to explain. After some thinking and hitting the wall with my head :) may I bring my words in addition ? Please tell me if I am wrong. So statistics helps to find / allocate the data and predict the number of rows that would come. Then the SQL Server makes the decision whether it can use an index or not to collect the data. Are you Japanese ? I mean you could be just working and living there. Big Thank you.
@arslanov1886
@arslanov1886 4 дня назад
Correct. Yes, I am just living and working here in Japan :)
@iliashterev38
@iliashterev38 3 дня назад
@@arslanov1886 All right. Thank you. For a moment I thought I asked something inappropriate. I love learning about Japan. It is so unique and exotic in many ways compared to the western world. I have many things to sort out now but some day I will look for you in LinkedIn and ask you if you would have time share some of your insights.