Giter Site home page Giter Site logo

i100yanov / internals-viewer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danny-sg/internals-viewer

0.0 0.0 0.0 19.2 MB

Internals Viewer is a visualisation tool for viewing the internals of the SQL Server Storage Engine

License: GNU General Public License v3.0

C# 97.56% TSQL 2.44%

internals-viewer's Introduction

Internals Viewer 2024

This is based on the codebase for Internals Viewer from 2007. The code has been upgraded to .NET Core 8 and I've started modernizing things. I'll hopefully be able to refactor and add testing to bring the 16 year old code back to life and up to scratch.

Introduction

Internals Viewer is a visualisation tool for viewing the internals of the SQL Server Storage Engine.

Background

In 2006 I started looking into SQL Server internals to get a better understanding of what was going on inside of a database. SQL Server isn't a black box where what happens inside is a mystery. There's a huge amount of information on what it is doing but to understand it requires knowledge about the internal architecture. What is a Clustered Index? What is a Heap? What is the difference between a DATETIME and SMALLDATETIME? What is the effect on my table structure if a field is NULL vs NOT NULL, or CHAR vs VARCHAR?

To get answers to these questions and to learn about internals if you want to see it and experiment you have to start digging around using system tables and undocumented commands. There is a lot of information out there in articles, blogs, and books. I've listed some below.

When I started doing this I found a couple of things. The first thing was it's not complicated! I was suprised at how accesible all of the information was. The second thing I found was the techniques to view internals were cumbersome. You have to query sys tables, take values and convert them from binary, run a DBCC command, view the results, follow to another page, run another command etc.

Internals Viewer started to make it easier to navigate around the internals of a database and view the data structures. Over time it has implemented more of the interpretation to help with explanation of structures in the user interface.

Concepts

Pages

Data1 is managed inside SQL Server with 8KB chunks of data called Pages. All pages have a 96 byte header that give detail about the page, including things like the page type and links to other pages.

Pages types include allocation structures, index data, table data etc.

Page Address

Pages are identified with a page address in the format File Id:Page Id. This is where the page is located in the database (MDF/NDF) files.

Allocations

Extents and oages on the Allocation Map

The first thing you see when you open Internals Viewer is the Allocation Map. This is a visualisation of the internal structures SQL Server uses to track the physical location of objects.

Each block represents a page. Pages are tracked in groups of 8 pages called extents. An extent covers 64 KB in the file.

The different colours in the Allocation Map represent different objects.

Clicking on a page will open it in the Page Viewer.

Resources

Websites

Books

Future Development

I've added a test winforms app to get it running. Once I've done a bit more refactoring I'll look into adding it in as a SSMS extension again.

After that I'll look into if any new features since SQL Server 2008 can be added, for example if Column Store indexes.

Footnotes

  1. This applies to the MDF/NDF database files. Functionality such as the In-Memory OLTP use different data structures โ†ฉ

internals-viewer's People

Contributors

danny-sg avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.