SQL Kiwi (1/28/2012)
Opinions vary on this, but my own view is that it is only worth creating extra equally-sized tempdb files if you are experiencing allocation contention.
My preference too, although if I have a case where I know that no one will bother to monitor, I may be proactive and create a 2nd file even without seeing contention.
That said, that script is wrong. It's looking at page numbers that are not PFS, GAM, SGAM pages (other than the 1st set in the file).
PFS - first PFS page is page 1, after that where PageNo % 8088 = 0 (no -1 required)
GAM - first GAM is at page 2, after that where PageID % 511232 = 0 (no -2 required)
SGAM - first SGAM is at page 3, after that where (PageID-1)%511232=0 (not -3 )
Easy to prove, by the formula in the script posted, page 511234 (511234 - 2 = 511232. 511232 % 511232 = 0) should be a GAM page, ie page type 8. Go and look at that in a DB big enough, and I get this:
m_pageId = (0:0) m_headerVersion = 0 m_type = 0
m_typeFlagBits = 0x0 m_level = 0 m_flagBits = 0x0
m_objId (AllocUnitId.idObj) = 0 m_indexId (AllocUnitId.idInd) = 0 Metadata: AllocUnitId = 0
Metadata: PartitionId = 0 Metadata: IndexId = -1 Metadata: ObjectId = 0
m_prevPage = (0:0) m_nextPage = (0:0) pminlen = 0
m_slotCnt = 0 m_freeCnt = 0 m_freeData = 0
m_reservedCnt = 0 m_lsn = (0:0:0) m_xactReserved = 0
m_xdesId = (0:0) m_ghostRecCnt = 0 m_tornBits = 0
That's just an unallocated page. Check my formula though (PageID % 511232), it says that 511232 is a GAM.
m_pageId = (1:511232) m_headerVersion = 1 m_type = 8
m_typeFlagBits = 0x0 m_level = 0 m_flagBits = 0x200
m_objId (AllocUnitId.idObj) = 99 m_indexId (AllocUnitId.idInd) = 0 Metadata: AllocUnitId = 6488064
Metadata: PartitionId = 0 Metadata: IndexId = 0 Metadata: ObjectId = 99
m_prevPage = (0:0) m_nextPage = (0:0) pminlen = 90
m_slotCnt = 2 m_freeCnt = 6 m_freeData = 8182
m_reservedCnt = 0 m_lsn = (6664:3406110:62) m_xactReserved = 0
m_xdesId = (0:0) m_ghostRecCnt = 0 m_tornBits = 533630942
Trivial to show similarly that 511233 is an SGAM.
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass