Download presentation
Presentation is loading. Please wait.
1
Hustle and Bustle of SQL Pages
Jacques Mostert SQLAdventurar
2
Proudly brought to you by
Platinum Gold Silver Bronze
3
QUERY Overview Query -> magic -> results
4
Relational Engine Query Plan Parse Optimize Normalize Buffer Pool
Task Query Plan Parse Task Task Optimize Normalize Buffer Pool Storage Engine Plan Cache Computer starts query Query is executed by user Goes into a task queue Gets a worker/scheduler (REMEMBER SQL IS LAZY) Does a HASH on the query and checks the plan cache Start language event Parse Normalize Optimize – Engine is MS Holy Grail and closely guarded secret It has 4 stages -pre optimization – trivial plan -transaction processing when cost is < 0.2 -Quick plan when cost is <1 -Full Optimization Execution plan Allocate Memory IO Subsystem
5
Relational Engine Parse Query Plan Optimize Normalize Query Executer
Task Query Plan Task Task Optimize Normalize Query Executer Buffer Pool Storage Engine Plan Cache Query Executer Storage engine Access method manager Buffer manager BM checks the data cache and checks for the page it needs If page is there no need to go to disc if not then it needs to load the page to the buffer pool Then the request is passed to the IO Manager IO Manager goes to the disc gets the data and sends it all the way back. Why does the buffer pool matter? HDD 200MB/s, SDD MB/s DDR6.4GB to 17GB/s Access Method Buffer Manager Data Cache IO Subsystem IO Manager
6
What we visualize a SQL page to look like
7
What it actually looks like
Not going to discuss page structures SQL does not read parts of a page but the whole page If you set statistics on 128 pages = 1MB pages = 1GB
8
PAGE (8Kb)
9
EXTEND (64Kb) Mixed or Uniform
10
Sector Size
11
Select (Read) Insert (Write) Delete (Remove) Update
12
Memory / Buffer
13
TempDB / Workspace Tempdb is used by the SQL OS for operations, snapshot isolation, always on, index rebuild and so forth TempDB is SQL Server dumpster or public toilet. Everything or everyone uses it Sorting is not limited to your memory. Your query is not that important that SQL will give it all to you Memory is shared and used to cache data, cache execution plans and executing your query
14
Pile Of “HEAP” Data rows stored random Pages are everywhere HEAPS are not bad per-say there could be an advantage to having a HEAP when you insert “random” data and read large chunks without the need for sorting
15
Cluster Confusion Explain why it is bad to create a clustered index on a column that does not store sequential number like GUID If a table only has a clustered index it is going to be slow. Because there is then only one copy of the table same as the HEAP
16
Nonclustered Index Nonclustered index – create copies of columns
Clusteres index included
17
This is effectively a covering index for the specific query
This is effectively a covering index for the specific query. In the perfect world there would be an index like this for every query.
18
Table Lock
19
Page Locking
20
Row Locking
21
Sorting Group By Create work space Write down while sql reads
22
Compression
24
THANK YOU! Platinum Gold Silver Bronze
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.