A deeper look into Extents
Chronicles of SQL Server's Storage Internals - Part 5
I briefly mentioned Extents before, but they deserve more attention before we proceed with other topics.
As a reminder, Extents are really simple concept - they are just a name given to eight consecutive pages. That's it!
So why do they exist then?
They ease up memory management really. It's easier to allocate 8 consecutive pages than to do it at one page per time.
We mentioned before that a single page is of a fixed size. 8KB to be more precise.
That means that Extent has a size of 64KB (8 pages time 8KB).
What's interesting to mention is that there are TWO types of Extents - Mixed and Uniform ones.
As space becomes cheaper, Mixed ones are becoming less used, but they still exist. They are just a logical grouping of 8 pages that can belong to DIFFERENT entities (e.g. one page might belong to data stored in Table A, another page may contain data belonging to Table B, etc.). They are really a cocktail of pages and are useful when you don't really know how many pages will you need (which will become interesting in next article when we discuss Allocation Maps).
On the other hand, Uniform Extents are, as the name implies - a solid block of 8 Pages belonging to ONE SINGLE Entity. Think of 8 pages belonging to specific Table; or Index. This is really powerful because what it tells you upfront is -- once you locate the FIRST page of extent, you can easily read all 8 of them as they are guaranteed to belong to the same Entity. It's sequential reading at its finest!
And that's actually all there is to them, really! I said they are a simple concept and, you know, they really ARE :)
It's important to remember this info before we jump into Allocation Maps which put a bit more organization on top of randomly spread Extents. But that's a topic for another time!
Hope you enjoyed it!
Thanks for reading Bitesized Engineering! Subscribe for free to receive new posts and support my work.