terça-feira, 25 de agosto de 2009

Estatísticas e ShowPlan de uma Query.

Para exibir as estatísticas e o show plan de uma query:

Os exemplos abaixo mostram os tipos de estatísticas.
/**************************************************************************************************************//* *//* Statistics */ /* */ /**************************************************************************************************************/

SET STATISTICS TIME ON
go
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Join sys.objects B On B.object_id = A.id
go
SET STATISTICS TIME Off

SET STATISTICS IO ON;

GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Join sys.objects B On B.object_id = A.id
GO
SET STATISTICS IO OFF;


SET STATISTICS PROFILE On
GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Join sys.objects B On B.object_id = A.id
GO
SET STATISTICS PROFILE Off

SET STATISTICS XML ON

GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Join sys.objects B On B.object_id = A.id
GO
SET STATISTICS XML Off

/**************************************************************************************************************//* *//* ShowPlan */ /* */ /**************************************************************************************************************/
SET SHOWPLAN_ALL ON;

GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Join sys.objects B On B.object_id = A.id
GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Hash Join sys.objects B On B.object_id = A.id

GO
SET SHOWPLAN_ALL OFF;
GO

SET SHOWPLAN_TEXT ON;

GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Join sys.objects B On B.object_id = A.id
GO
Select B.object_id, B.name as Tabela, A.name from syscolumns A Inner Hash Join sys.objects B On B.object_id = A.id

GO
SET SHOWPLAN_TEXT Off;
GO


Nenhum comentário:

Postar um comentário