Monday, September 26, 2016

Defination of IAM, GAM and SGAM

GAM: Global Allocation Map

Provides the information about the extents which are available for allocation.
Covers 4GB interval of Data.

SGAM: Shared Global Allocation Map


Provides the information about the mix extents which have at least 1 page available for allocation.
Covers 4GB interval of Data.

PFS:
PFS stands for Page Free Space, but the PFS page tracks much more than that. As well as GAM intervals, every database file is also split (conceptually) into PFS intervals. A PFS interval is 8088 pages, or about 64MB. A PFS page doesn’t have a bitmap – it has a byte-map, with one byte for each page in the PFS interval (not including itself).

Used to track how much free space is on pages
Covers 64MB interval of Data.

IAM: Index Allocation Map

Special internal page on data file that tracks all extent allocation for tables, indexes and partitions.
Basically, lets SQL Server know what extent belongs to what specific entity.
Covers 4GB interval of Data.

PFS,GAM and SGAM help SQL Server to determine where free space is and how much so that it can allocate it appropriately without having to scan all the pages.
IAM pages and Indexes help SQL Server fulfill queries

Thursday, September 22, 2016

Findind when the statistics have updated.


select si.name as index_name, STATS_DATE(si.OBJECT_ID,index_id) as statsupdatedate, OBJECT_NAME(si.object_id) as tablename,sch.name as scheemaname
from sys.indexes si, sys.schemas sch,sys.tables st where si.object_id=st.object_id and st.schema_id=sch.schema_id
update statistics owner.objectname