Commit e47c44d5 authored by Your Name's avatar Your Name
Browse files

initial commit

parent 83507252
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
PRINT '-----------------------------------------------------------------------------------------------------------------'
PRINT '-- PerformanceCollector.AdHocPlanCacheBloat '
PRINT '-----------------------------------------------------------------------------------------------------------------'
IF OBJECT_ID('PerformanceCollector.AdHocPlanCacheBloat') IS NULL
BEGIN 
  Create table PerformanceCollector.AdHocPlanCacheBloat
  ( CurrTime datetime
  , ServerName varchar(200)
  , [QueryText] nvarchar(max)
  ,	size_in_bytes bigint
  )
END
ELSE BEGIN
	Print 'Table already exists, performing Alters (if required)...'
END
GO

+0 −36
Original line number Diff line number Diff line
--blow the table away and recreate it. 
IF NOT EXISTS (select * from sys.objects where object_id = object_id('PerformanceCollector.BlockAndWaitStats'))
BEGIN
CREATE TABLE PerformanceCollector.BlockAndWaitStats 
	(ObjId			bigint identity(1,1) not null			--key
	,CurrTime		datetime		NOT NULL				--time of the block/wait.
	,spid			smallint		NOT NULL				--SPID		
	,BlockingSpid	smallint		NOT NULL				--SPID of the session that is blocking the request.  0 is not blocked.  -2 is orphaned
																--dist transaction, -4 is undetermined due to state transitions 
	,IsHeadBlocker	bit				NOT NULL				--finds any blocking tasks that are not themselves blocked.  
	,DBName			varchar(50)		NULL					--database against which the request arrived		
	,waittime		bigint			NULL				--total wait time for this wait type, in ms, inclusive of signal_wait_time. 
	,wait_type		varchar(60)	NULL					--name of the wait type, ie LCK_M_X, WRITELOG, NETWORKIO,etc
	,wait_resource	varchar(512)	NULL					--if the request is blocked then what is it waiting on, ie db:file:objectid
	,status			varchar(30)	NOT NULL				--status of the request (running, runnable, sleeping, suspended, etc)
	,CommandType	varchar(32)		NOT NULL				--type of command (DBCC, SELECT, INSERT, BACKUP LOG, etc)
	,cpu_ms			int				NULL					--CPU used (in ms) at the request level
	,physical_io		bigint			NULL
	,SQLText		varchar(MAX)	NULL					--text of the request
	,program_name	varchar(256)	NOT NULL				--from what application
	,hostname		varchar(256)	NULL					--who made the call
	,login_name		varchar(128)	NOT NULL				--SQL Server login name under which the session is currently executing. 
	,last_batch		datetime		NOT NULL				--Timestamp when the request arrived.
	,open_tran		smallint		NOT NULL				--number of open transactions for the request
	,tran_iso_level	smallint		NULL					--transaction isolation level of the request
	,statement_start_offset  int		NULL					--used to calculate StatementText in the API view
	,statement_end_offset int		NULL
	,TransactionName nvarchar(256) NULL
)
END;
GO
IF NOT EXISTS (SELECT 1 from SYS.INDEXES where name='BlockAndWaitStats_CL' and object_id = object_id('PerformanceCollector.BlockAndWaitStats'))
   CREATE Clustered INDEX BlockAndWaitStats_CL ON PerformanceCollector.BlockAndWaitStats(CurrTime)
GO

+0 −22
Original line number Diff line number Diff line
PRINT '-----------------------------------------------------------------------------------------------------------------'
PRINT '-- PerformanceCollector.BufferStats '
PRINT '-----------------------------------------------------------------------------------------------------------------'
IF OBJECT_ID('PerformanceCollector.BufferStats') IS NULL
BEGIN 
  Create table PerformanceCollector.BufferStats
  ( CurrTime datetime
  , ServerName varchar(200)
  , DbName varchar(200)
  , ObjectName varchar(200)
  , index_id int
  , BufferSizeMB bigint
  , BufferCount bigint
  , CompressionType varchar(200)
  , TypeDesc varchar(200)
  , [Rows] bigint
  )
END
ELSE BEGIN
	Print 'Table already exists, performing Alters (if required)...'
END
GO
 No newline at end of file
+5 −10
Original line number Diff line number Diff line
@@ -2,16 +2,11 @@ IF OBJECT_ID('PerformanceCollector.Config') IS NULL
BEGIN
	CREATE TABLE PerformanceCollector.Config(
		ConfigSetting varchar(40) NOT NULL,
		ConfigInstance varchar(128) NULL,
		ConfigValueInt int NULL,
		ConfigValueText varchar(4000) NULL
		ConfigSettingValue varchar(128) NULL,
		RunIntervalMins decimal(18,2) NULL,
		LastRunTime datetime NULL,
		Notes varchar(4000) NULL
		) 
END

GO
 No newline at end of file





+0 −105
Original line number Diff line number Diff line
/*
PRINT '-----------------------------------------------------------------------------------------------------------------'
PRINT '-- DBA_PM_ProcsPrev '
PRINT '-----------------------------------------------------------------------------------------------------------------'
IF OBJECT_ID('DBA_PM_ProcsPrev') IS NULL
BEGIN
	CREATE TABLE DBA_PM_ProcsPrev(
		Spid smallint NOT NULL,
		HostProcess int NOT NULL,
		Ecid smallint NOT NULL,
		IsActive smallint NOT NULL,
		login sysname NULL,
		status varchar(30) NULL,
		dbname sysname NULL,
		HostName varchar(128) NULL,
		Cmd varchar(16) NULL,
		appl varchar(128) NULL,
		Open_Tran smallint NULL,
		blking smallint NOT NULL,
		blkby smallint NULL,
		blklvl smallint NOT NULL,
		waittime bigint NULL,
		waittype binary(2) NULL,
		lastwaittype varchar(64) NULL,
		waitresource varchar(512) NULL,
		cpu bigint NULL,
		Physical_io bigint NULL,
		memusage int NULL,
		now datetime NOT NULL,
		login_time datetime NULL,
		last_batch datetime NULL,
		SinceLastBatch numeric(14, 3) NULL,
		sql_handle binary(20) NOT NULL,
		stmt_start int NOT NULL,
		stmt_end int NOT NULL,
		current_sp int NULL,
		curdbid smallint NULL,
		curstmt varchar(255) NULL,
		delay int NOT NULL,
		inputbuffer varchar(4000) NOT NULL
		) 
END
ELSE BEGIN
	Print 'Table already exists, performing Alters (if required)...'

	--SQL2005 Changes (255) -> (4000)
	PRINT 'Altering inputbuffer...'
	ALTER TABLE DBA_PM_ProcsPrev ALTER COLUMN inputbuffer varchar(4000) NOT NULL
	PRINT 'Altering curstmt...'
	ALTER TABLE DBA_PM_ProcsPrev ALTER COLUMN curstmt varchar(255) NULL


	-- int -> bigint
	PRINT 'Altering waittime...'
	ALTER TABLE DBA_PM_ProcsPrev ALTER COLUMN waittime bigint NULL

	PRINT 'Altering CPU...'
	ALTER TABLE DBA_PM_ProcsPrev ALTER COLUMN CPU bigint NULL

	-- numeric(10,3) -> numeric(14,3)
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='last_since')
	BEGIN
		PRINT 'Altering last_since...'
		ALTER TABLE DBA_PM_ProcsPrev ALTER COLUMN last_since numeric(14, 3) NULL
	END




	-- clprocess -> HostProcess
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='clprocess')
	  exec sp_rename 'DBA_PM_ProcsPrev.clprocess', 'HostProcess','COLUMN'
	-- active -> IsActive
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='active')
	  exec sp_rename 'DBA_PM_ProcsPrev.active', 'IsActive','COLUMN'
	-- physio -> Physical_io
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='physio')
	  exec sp_rename 'DBA_PM_ProcsPrev.physio', 'Physical_io','COLUMN'
	-- last_Since -> SinceLastBatch
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='last_since')
	  exec sp_rename 'DBA_PM_ProcsPrev.last_since', 'SinceLastBatch','COLUMN'
	-- host -> HostName
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='host')
	  exec sp_rename 'DBA_PM_ProcsPrev.host', 'HostName','COLUMN'
	-- Command -> cmd
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='Command')
	  exec sp_rename 'DBA_PM_ProcsPrev.Command', 'Cmd','COLUMN'
	-- opntrn -> Open_Tran
	if exists (select top 1 * from syscolumns where OBJECT_NAME(id)='DBA_PM_ProcsPrev' and name='opntrn')
	  exec sp_rename 'DBA_PM_ProcsPrev.opntrn', 'Open_Tran','COLUMN'

	-- bit -> smallint
	PRINT 'Altering IsActive...'
	ALTER TABLE DBA_PM_ProcsPrev ALTER COLUMN IsActive smallint NOT NULL


END
GO






*/
 No newline at end of file
Loading