
Pminlen = 4 m_slotCnt = 1 m_freeCnt = 7538 M_objId (AllocUnitId.idObj) = 98834 m_indexId (AllocUnitId.idInd) = 7936 M_typeFlagBits = 0x0 m_level = 0 m_flagBits = 0x8000 If we take the file_id and page_id values from the query results above and run DBCC PAGE with them, we can see the actual physical page contents: DBCC TRACEON (3604) -send display to the clientĭBCC PAGE (tempdb, 1, 1912, 3) -database, file_id, page_id, 3 to show page contentsĭBCC TRACEOFF (3604) -reset display back to the error log ║ partition_id ║ colName ║ IsInrow ║ IsSparse ║ IsRecordPrefixCompressed ║ IsSymbol ║ PrefixBytes ║ InRowLength ║ file_id ║ page_id ║ slot_id ║ This query uses the undocumented, and unsupported, functions sys.fn_RowDumpCracker and sys.fn_PhyslocCracker to show some interesting details about the table: SELECT rdc.*ĬROSS APPLY sys.fn_RowDumpCracker(%%rowdump%%) rdcĬROSS APPLY sys.fn_physlocCracker(%%physloc%%) plc Now we'll insert a single row: INSERT INTO dbo.varchartest (varchar30, varchar255, varchar256) In case you are interested in storage internals, you can use the following tiny test to better understand how SQL Server stores uncompressed row-store data.įirst, we'll create a table where we can store columns of various sizes: IF OBJECT_ID(N'dbo.varchartest', N'U') IS NOT NULL If you design columns with a generic width, such as (255), you may run into this warning far more often than expected. 1700 bytes is the maximum key size for non-clustered indexes on newer versions of SQL Server. For some combination of large values, the insert/update operation will fail.ĩ00 bytes is the maximum key size for clustered indexes (and non-clustered indexes on SQL Server 2012 and older). The index 'IX_WideIndex_01' has maximum length of 1110 bytes. Warning! The maximum key length is 900 bytes. The attempt to create the index above results in this warning: Indexes on columns that are oversize can result in errors being generated: CREATE TABLE dbo.WideIndex Having oversized columns can be detrimental to performance. SQL Server uses the size of each column in it's query optimizer to understand estimated memory requirements for query processing. This is especially prudent advice if you ever need to index a column, or if you are using a column as a primary key and it has foreign key references.

If you only need 30 characters, why create a column that can handle 255? I'm so glad you're not advocating using varchar(max) for your string columns.

Do NOT use a "standard" size for each column. Size each and every column appropriately.
