<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL - Etienne ZINZINDOHOUE &#187; OUTILS</title>
	<atom:link href="https://blog.developpez.com/zinzineti/pcategory/outils/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/zinzineti</link>
	<description>Bases de données</description>
	<lastBuildDate>Thu, 09 Aug 2012 13:57:35 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Estimation de la taille d&#8217;une base de données</title>
		<link>https://blog.developpez.com/zinzineti/p9646/sql-server-2005/estimation_de_la_taille_d_une_base_de_do</link>
		<comments>https://blog.developpez.com/zinzineti/p9646/sql-server-2005/estimation_de_la_taille_d_une_base_de_do#comments</comments>
		<pubDate>Sat, 08 Jan 2011 13:57:51 +0000</pubDate>
		<dc:creator><![CDATA[zinzineti]]></dc:creator>
				<category><![CDATA[OUTILS]]></category>
		<category><![CDATA[SQL SERVER 2000]]></category>
		<category><![CDATA[SQL SERVER 2005]]></category>
		<category><![CDATA[SQL SERVER 2008]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[D&#8217;habitude pour faire une estimation de la taille d&#8217;une base de données j&#8217;utilise l&#8217;outil POWER AMC. En fonction de différents paramètres : nombre de lignes dans chaque table, index, &#8230; POWER AMC indique une estimation de la taille de la base. Mais la méthode de calcul n&#8217;est pas affichée par POWER AMC &#8230; En fouillant sur le net, je suis tombé sur une procédure écrite par Tim Laqua pour faire une estimation de la taille [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>D&rsquo;habitude pour faire une estimation de la taille d&rsquo;une base de données j&rsquo;utilise l&rsquo;outil POWER AMC. En fonction de différents paramètres : nombre de lignes dans chaque table, index, &#8230; POWER AMC indique une estimation de la taille de la base. Mais la méthode de calcul n&rsquo;est pas affichée par POWER AMC &#8230;<br />
En fouillant sur le net, je suis tombé sur une procédure écrite par Tim Laqua pour faire une estimation de la taille d&rsquo;une table; la procédure stockée de Tim Laqua est basée sur un mode de calcul clair proposé par Microsoft qui est <a href="http://msdn.microsoft.com/en-us/library/ms178085.aspx">ici</a><br />
Dans ce billet, nous allons comparer les résultats donnés par la procédure stockée de Tim Laqua et l&rsquo;outil POWER AMC 9.5<br />
<span id="more-113"></span><br />
Voici la DDL de la table de test (cette table est tiré du livre SQL Server 2008 Internals &#8211; page 223)<br />
Pour des raisons de simplicité, nous n&rsquo;allons pas poser de clé primaire ni d&rsquo;index sur cette table.</p>
<blockquote>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2">CREATE</font></font><font color="#000000" size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">TABLE</font></font><font size="2"><font color="#000000"> customer</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#808080" size="2"><font color="#808080" size="2">(</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_id </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">smallint</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_name </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_addr1 </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_addr2 </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_city </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_state </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">char</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">2</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_postal_code </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">10</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_phone </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">20</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_fax </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">20</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_email </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">30</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL,</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font size="2">cust_web_url </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">100</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font><font size="2"> </font><font color="#808080" size="2"><font color="#808080" size="2">NULL</font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></span></span></p>
</p>
</blockquote>
<p>Avec 1000 lignes dans la table voici le résultat fournit par POWER AMC 9.5</p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">&#8211;POWER AMC 9.5 </font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">Estimation de la taille de la base de donnes &quot;ModeleConceptuelDonnees_1&quot;&#8230;</font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">Nombre                       Taille estime                Objet</font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-   &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;       &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">1.000                       405 Ko                        Table &quot;customer&quot; </font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-   &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;       &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2">                           405 Ko Espace total <font color="#008000" size="2"><font color="#008000" size="2">estim&eacute;<span style="display: none"> </span></font></font></font></font></font></font></span></span></p>
<p>
	<span style="font-family: courier new, courier, monospace"><span style="font-size: 10px"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#008000" size="2"><font color="#008000" size="2"><span style="display: none"> </span></font></font></font></font></span></span></p>
<p>Nous allons maintenant utiliser la procédure de Tim Laqua. cette procédure est détaillée <a href="http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/">ici</a></p>
<p><strong>&#8211;> La table de définition des types : les types Geography et Geometry ne sont pas pris en compte</strong></p>
<blockquote>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CREATE TYPE TableColumnDefinition AS TABLE <br />
&nbsp; ([DataType] VARCHAR(16) NOT NULL <br />
&nbsp; ,[Length] INT <br />
&nbsp; ,[IsKey] BIT <br />
&nbsp; ,[DataLength] AS <br />
&nbsp; &nbsp; CASE &nbsp;<br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'BIT' THEN 0.125 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'TINYINT' THEN 1 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'SMALLINT' THEN 2 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] IN ('INT', 'SMALLMONEY', 'REAL', 'SMALLDATETIME') THEN 4 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] IN ('BIGINT', 'DATETIME', 'MONEY') THEN 8 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'UNIQUEIDENTIFIER' THEN 16 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'NVARCHAR' THEN [Length] * 2 + 2 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'VARCHAR' THEN [Length] + 2 &nbsp;-- DOESN'T SUPPORT MAX <br />
&nbsp; &nbsp; &nbsp; WHEN [Datatype] = 'DATE' THEN 3 &nbsp;<br />
&nbsp; &nbsp; &nbsp; WHEN [Datatype] = 'TIME' THEN 5 -- Worst case <br />
&nbsp; &nbsp; &nbsp; WHEN [Datatype] = 'DATETIME2' THEN 8 -- Worst case <br />
&nbsp; &nbsp; &nbsp; WHEN [Datatype] = 'DATETIMEOFFSET' THEN 10 -- Worst case <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'CHAR' THEN [Length] <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'NCHAR' THEN [Length] * 2 + 2 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'BINARY' THEN [Length] <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'VARBINARY' THEN [Length] + 2 <br />
&nbsp; &nbsp; &nbsp; WHEN [Datatype] = 'TIMESTAMP' THEN 8 <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'XML' THEN [Length] &nbsp;-- Estimate an average size in bytes, 2GB max <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] IN ('DECIMAL', 'NUMERIC') THEN &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; CASE &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] BETWEEN 1 AND 9 &nbsp;THEN 5 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] BETWEEN 10 AND 19 THEN 9 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] BETWEEN 20 AND 28 THEN 13 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] BETWEEN 29 AND 38 THEN 17 <br />
&nbsp; &nbsp; &nbsp; &nbsp; END <br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] = 'FLOAT' THEN <br />
&nbsp; &nbsp; &nbsp; &nbsp; CASE <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] BETWEEN 1 AND 24 THEN 4 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] BETWEEN 25 AND 53 THEN 8 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [Length] IS NULL THEN 8 &nbsp;-- Default n is 53 <br />
&nbsp; &nbsp; &nbsp; &nbsp; END <br />
&nbsp; &nbsp; &nbsp; ELSE 0 <br />
&nbsp; &nbsp; END <br />
&nbsp; ,[IsVariableLength] AS <br />
&nbsp; &nbsp; CASE &nbsp;<br />
&nbsp; &nbsp; &nbsp; WHEN [DataType] IN ('VARCHAR', 'NVARCHAR', 'VARBINARY') THEN 1 <br />
&nbsp; &nbsp; &nbsp; ELSE 0 <br />
&nbsp; &nbsp; END)</div></div>
</blockquote>
<p><strong>&#8211;> La procédure stockée de calcul</strong></p>
<blockquote>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">/************************************************************************************* <br />
*** <br />
*** Procedure: &nbsp; &nbsp; &nbsp;[Utility_EstimateClusteredIndexSize] <br />
*** Purpose: &nbsp; &nbsp; &nbsp; &nbsp;Estimates the amount of space needed for a given clustered index <br />
*** Methodology: &nbsp; &nbsp;http://msdn.microsoft.com/en-us/library/ms178085.aspx <br />
*** &nbsp; &nbsp; &nbsp;<br />
*** &nbsp; &nbsp; &nbsp;<br />
*** Author: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tim Laqua <br />
*** Date Created: &nbsp; &nbsp;2009-10-15 &nbsp;<br />
*** &nbsp;<br />
*** Revision History <br />
*** Date &nbsp; &nbsp;Author &nbsp; &nbsp; &nbsp;Description <br />
*** 2009-10-15 &nbsp;tl &nbsp; &nbsp; &nbsp; &nbsp;Created <br />
*************************************************************************************/ <br />
ALTER PROCEDURE [dbo].[Utility_EstimateClusteredIndexSize] <br />
( <br />
&nbsp; &nbsp;@Num_Rows FLOAT <br />
&nbsp; ,@ClusteredIndexIsUnique BIT <br />
&nbsp; ,@Fill_Factor FLOAT <br />
&nbsp; ,@TableColumn TableColumnDefinition READONLY <br />
) <br />
AS &nbsp;<br />
&nbsp;<br />
SET NOCOUNT ON <br />
&nbsp;<br />
DECLARE <br />
&nbsp; &nbsp;@Num_Cols FLOAT = 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-- total number of columns (fixed-length and variable-length) <br />
&nbsp; ,@Fixed_Data_Size FLOAT = 0 &nbsp; &nbsp; &nbsp;-- total byte size of all fixed-length columns <br />
&nbsp; ,@Num_Variable_Cols FLOAT &nbsp;= 0 &nbsp; &nbsp; &nbsp;-- number of variable-length columns <br />
&nbsp; ,@Max_Var_Size FLOAT &nbsp;= 0 &nbsp; &nbsp; &nbsp; &nbsp;-- maximum byte size of all variable-length columns <br />
&nbsp; ,@Variable_Data_Size FLOAT = 0 <br />
&nbsp;<br />
DECLARE @VAR TABLE <br />
&nbsp; ([Name] VARCHAR(64) <br />
&nbsp; ,[VALUE] FLOAT <br />
&nbsp; ,[DisplayValue] AS <br />
&nbsp; &nbsp; CASE <br />
&nbsp; &nbsp; &nbsp; WHEN LOWER([Name]) LIKE '%size%' OR LOWER([Name]) LIKE '%space%' THEN <br />
&nbsp; &nbsp; &nbsp; &nbsp; CASE &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [VALUE] &lt; 1024 THEN CAST(CAST(ROUND([VALUE], 3) AS NUMERIC(16,0)) AS VARCHAR(16)) + ' B' <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [VALUE] &lt; 1024*1024 THEN CAST(CAST(ROUND([VALUE]/1024, 3) AS NUMERIC(16,3)) AS VARCHAR(16)) + ' KB' <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN [VALUE] &lt; 1024*1024*1024 THEN CAST(CAST(ROUND([VALUE]/1024/1024, 3) AS NUMERIC(16,3)) AS VARCHAR(16)) + ' MB' <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ELSE CAST(CAST(ROUND([VALUE]/1024/1024/1024, 3) AS NUMERIC(16,3)) AS VARCHAR(16)) + ' GB' <br />
&nbsp; &nbsp; &nbsp; &nbsp; END <br />
&nbsp; &nbsp; &nbsp; ELSE CAST(FLOOR([VALUE]) AS VARCHAR(16)) <br />
&nbsp; &nbsp; END) <br />
&nbsp;<br />
&nbsp;<br />
-- Leaf level data <br />
SELECT &nbsp;<br />
&nbsp; &nbsp;@Num_Variable_Cols = COUNT(1) <br />
&nbsp; ,@Max_Var_Size = ISNULL(SUM([DataLength]), 0) <br />
FROM @TableColumn WHERE [IsVariableLength] = 1 <br />
&nbsp;<br />
SELECT &nbsp;<br />
&nbsp; &nbsp;@Num_Cols = COUNT(1) + @Num_Variable_Cols <br />
&nbsp; ,@Fixed_Data_Size = CEILING(ISNULL(SUM([DataLength]), 0)) <br />
FROM @TableColumn WHERE [IsVariableLength] = 0 <br />
&nbsp;<br />
&nbsp;<br />
INSERT INTO @VAR VALUES ('@Fixed_Data_Size', @Fixed_Data_Size) <br />
&nbsp;<br />
IF @ClusteredIndexIsUnique &lt;&gt; 0 <br />
BEGIN <br />
&nbsp; SET @Num_Cols += 1 <br />
&nbsp; IF @Num_Variable_Cols &gt; 0 <br />
&nbsp; &nbsp; SET @Num_Variable_Cols += 1 <br />
&nbsp; IF @Max_Var_Size &gt; 0 <br />
&nbsp; &nbsp; SET @Max_Var_Size += 4 <br />
END <br />
&nbsp;<br />
DECLARE @Null_Bitmap INT = CEILING(2 + ((@Num_Cols + 7) / 8)) <br />
INSERT INTO @VAR VALUES ('@Null_Bitmap', @Null_Bitmap) <br />
&nbsp;<br />
-- if there are variable columns <br />
IF @Num_Variable_Cols &gt; 0 <br />
&nbsp; SET @Variable_Data_Size = 2 + (@Num_Variable_Cols * 2) + @Max_Var_Size &nbsp;<br />
INSERT INTO @VAR VALUES ('@Num_Cols', @Num_Cols) <br />
INSERT INTO @VAR VALUES ('@Num_Variable_Cols', @Num_Variable_Cols) <br />
INSERT INTO @VAR VALUES ('@Max_Var_Size', @Max_Var_Size) <br />
&nbsp;<br />
DECLARE @Row_Size FLOAT = CEILING(@Fixed_Data_Size + @Variable_Data_Size + @Null_Bitmap + 4 ) <br />
INSERT INTO @VAR VALUES ('@Row_Size', @Row_Size) <br />
&nbsp;<br />
DECLARE @Rows_Per_Page FLOAT = FLOOR(8096 / (@Row_Size + 2)) <br />
INSERT INTO @VAR VALUES ('@Rows_Per_Page', @Rows_Per_Page) <br />
&nbsp;<br />
DECLARE @Free_Rows_Per_Page FLOAT = FLOOR(8096 * ((100 - @Fill_Factor) / 100) / (@Row_Size + 2) ) <br />
INSERT INTO @VAR VALUES ('@Free_Rows_Per_Page', @Free_Rows_Per_Page) <br />
&nbsp;<br />
DECLARE @Num_Leaf_Pages FLOAT = CEILING(@Num_Rows / (@Rows_Per_Page - @Free_Rows_Per_Page) ) <br />
INSERT INTO @VAR VALUES ('@Num_Leaf_Pages', @Num_Leaf_Pages) <br />
&nbsp;<br />
DECLARE @Leaf_space_used FLOAT = 8192 * @Num_Leaf_Pages <br />
INSERT INTO @VAR VALUES ('@Leaf_space_used', @Leaf_space_used) <br />
&nbsp;<br />
-- Index Information <br />
DECLARE <br />
&nbsp; &nbsp;@Num_Key_Cols FLOAT = 0 &nbsp; &nbsp; &nbsp;-- total number of key columns (fixed-length and variable-length) <br />
&nbsp; ,@Fixed_Key_Size FLOAT = 0 &nbsp; &nbsp; &nbsp;-- total byte size of all fixed-length key columns <br />
&nbsp; ,@Num_Variable_Key_Cols FLOAT = 0 &nbsp;-- number of variable-length key columns <br />
&nbsp; ,@Max_Var_Key_Size FLOAT = 0 &nbsp; &nbsp;-- maximum byte size of all variable-length key columns <br />
&nbsp;<br />
&nbsp;<br />
SELECT &nbsp;<br />
&nbsp; &nbsp;@Num_Variable_Key_Cols = COUNT(1) <br />
&nbsp; ,@Max_Var_Key_Size = ISNULL(SUM([DataLength]), 0) <br />
FROM @TableColumn &nbsp;<br />
WHERE &nbsp;<br />
&nbsp; [IsVariableLength] = 1 &nbsp;<br />
&nbsp; AND [IsKey] = 1 <br />
&nbsp;<br />
SELECT &nbsp;<br />
&nbsp; &nbsp;@Num_Key_Cols = COUNT(1) + @Num_Variable_Key_Cols <br />
&nbsp; ,@Fixed_Key_Size = ISNULL(SUM([DataLength]), 0) <br />
FROM @TableColumn &nbsp;<br />
WHERE &nbsp;<br />
&nbsp; [IsVariableLength] = 0 <br />
&nbsp; AND [IsKey] = 1 <br />
&nbsp;<br />
IF @ClusteredIndexIsUnique &lt;&gt; 0 <br />
BEGIN <br />
&nbsp; SET @Num_Key_Cols += 1 <br />
&nbsp; IF @Num_Variable_Key_Cols &gt; 0 <br />
&nbsp; &nbsp; SET @Num_Variable_Key_Cols += 1 <br />
&nbsp; IF @Max_Var_Key_Size &gt; 0 <br />
&nbsp; &nbsp; SET @Max_Var_Key_Size += 4 <br />
END <br />
INSERT INTO @VAR VALUES ('@Num_Variable_Key_Cols', @Num_Variable_Key_Cols) <br />
INSERT INTO @VAR VALUES ('@Max_Var_Key_Size', @Max_Var_Key_Size) <br />
INSERT INTO @VAR VALUES ('@Num_Key_Cols', @Num_Key_Cols) <br />
&nbsp;<br />
-- Who would seriously have a nullable key column? &nbsp;ridiculous. <br />
DECLARE @Index_Null_Bitmap FLOAT = 2 + ((@Num_Key_Cols + 7) / 8) &nbsp;<br />
INSERT INTO @VAR VALUES ('@Index_Null_Bitmap', @Index_Null_Bitmap) <br />
&nbsp;<br />
DECLARE @Variable_Key_Size FLOAT = 0 <br />
&nbsp;<br />
IF @Max_Var_Key_Size &gt; 0 <br />
&nbsp; SET @Variable_Key_Size = 2 + (@Num_Variable_Key_Cols * 2) + @Max_Var_Key_Size &nbsp;<br />
INSERT INTO @VAR VALUES ('@Variable_Key_Size', @Variable_Key_Size) <br />
&nbsp;<br />
DECLARE @Index_Row_Size FLOAT = @Fixed_Key_Size + @Variable_Key_Size + @Index_Null_Bitmap + 1 + 6 <br />
INSERT INTO @VAR VALUES ('@Index_Row_Size',@Index_Row_Size ) <br />
&nbsp;<br />
DECLARE @Index_Rows_Per_Page &nbsp;FLOAT = FLOOR(8096 / (@Index_Row_Size + 2)) <br />
INSERT INTO @VAR VALUES ('@Index_Rows_Per_Page', @Index_Rows_Per_Page) <br />
&nbsp;<br />
DECLARE @Non_Leaf_Levels FLOAT = 1 <br />
&nbsp;<br />
-- Log base @Non_Leaf_Levels hack <br />
WHILE (@Num_Leaf_Pages / @Index_Rows_Per_Page) &gt; POWER(@Index_Rows_Per_Page,@Non_Leaf_Levels) <br />
&nbsp; SET @Non_Leaf_Levels += 1 <br />
&nbsp;<br />
SET @Non_Leaf_Levels += 1 <br />
INSERT INTO @VAR VALUES ('@Non_Leaf_Levels', @Non_Leaf_Levels) <br />
&nbsp;<br />
-- Summation hack <br />
DECLARE &nbsp;<br />
&nbsp; &nbsp;@Num_Index_Pages FLOAT = 0 <br />
&nbsp; ,@Summand INT = @Non_Leaf_Levels <br />
&nbsp;<br />
WHILE @Summand &gt; 0 <br />
BEGIN <br />
&nbsp; SET @Num_Index_Pages += CEILING(@Num_Leaf_Pages/POWER(@Index_Rows_Per_Page, @Summand)) <br />
&nbsp; SET @Summand -= 1 <br />
END <br />
INSERT INTO @VAR VALUES ('@Num_Index_Pages', @Num_Index_Pages) <br />
&nbsp;<br />
DECLARE @Index_Space_Used FLOAT = 8192 * @Num_Index_Pages &nbsp;<br />
INSERT INTO @VAR VALUES ('@Index_Space_Used', @Index_Space_Used) <br />
&nbsp;<br />
DECLARE @Clustered_Index_Size FLOAT = @Leaf_Space_Used + @Index_Space_used <br />
INSERT INTO @VAR VALUES ('@Clustered_Index_Size', @Clustered_Index_Size) <br />
&nbsp;<br />
SELECT * FROM @VAR</div></div>
</blockquote>
<p><strong>&#8211;> Test de la procédure en utilisant la définition (DDL) de la table customer</strong></p>
<blockquote>
<p>
	<font color="#0000ff" size="2"><font color="#0000ff" size="2">DECLARE</font></font><font size="2"><font color="#000000"> @TableColumn TableColumnDefinition</font></font></p>
<p>
	<font color="#0000ff" size="2"><font color="#0000ff" size="2">INSERT</font></font><font color="#000000" size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">INTO</font></font><font size="2"><font color="#000000"> @TableColumn</font></font></p>
<p>
	<font color="#0000ff" size="2"><font color="#0000ff" size="2">VALUES</font></font><font size="2"><font color="#000000"> </font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;smallint&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,NULL,</font></font><font color="#000000" size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">50</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;CHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">2</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">10</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">20</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">20</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">30</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,(</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">&#39;VARCHAR&#39;</font></font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">100</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">0</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></p>
<p>
	<font color="#0000ff" size="2"><font color="#0000ff" size="2">EXEC</font></font><font color="#000000" size="2"> [dbo]</font><font color="#808080" size="2"><font color="#808080" size="2">.</font></font><font color="#000000" size="2">[Utility_EstimateClusteredIndexSize]</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> </font></font></p>
<p>
	<font color="#000000" size="2">@Num_Rows </font><font color="#808080" size="2"><font color="#808080" size="2">=</font></font><font color="#000000" size="2"> 1 </font><font color="#008000" size="2"><font color="#008000" size="2">&#8211; number of rows in the table</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font color="#000000" size="2">@ClusteredIndexIsUnique </font><font color="#808080" size="2"><font color="#808080" size="2">=</font></font><font color="#000000" size="2"> 0 </font><font color="#008000" size="2"><font color="#008000" size="2">&#8211; is it?</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font color="#000000" size="2">@Fill_Factor </font><font color="#808080" size="2"><font color="#808080" size="2">=</font></font><font color="#000000" size="2"> 90 </font><font color="#008000" size="2"><font color="#008000" size="2">&#8211; page fill factor</font></font></p>
<p>
	<font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font color="#000000" size="2">@TableColumn </font><font color="#808080" size="2"><font color="#808080" size="2">=</font></font><font color="#000000" size="2"> @TableColumn </font><font color="#008000" size="2"><font color="#008000" size="2">&#8211; definition of table columns </font></font></p>
</blockquote>
<p>
	<span style="font-size: 12px"><span style="font-family: courier new, courier, monospace"><font color="#008000"><font color="#008000">R&eacute;sultat</font></font></span></span></p>
<p>
	<span style="font-size: 12px"><span style="font-family: courier new, courier, monospace"><font color="#008000"><font color="#008000">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</font></font></span></span></p>
<p>
	<span style="font-size: 12px"><span style="font-family: courier new, courier, monospace"><font color="#008000"><font color="#008000">@Row_Size          431 octets</font></font></span></span></p>
<p>
	<span style="font-size: 12px"><span style="font-family: courier new, courier, monospace"><font color="#008000"><font color="#008000">@Rows_Per_Page      18</font></font></span></span></p>
</p>
<p>
	<span style="font-size: 14px"><strong><span style="font-family: courier new, courier, monospace"><font color="#008000"><font color="#008000">Pour les 1000 lignes, l&#39;estimation de la taille de la base = <font color="#008000">431</font> octets X 1000 = 421 Ko</font></font></span></strong></span></p>
<p><strong>&#8211;> Que peut-on dire ?</strong></p>
<p>POWER AMC estime la taille de la base à <strong>405 Ko</strong> et la procédure basée sur la méthodologie Microsoft affiche <strong>421 Ko</strong>. à mon humble avis ces résultats sont proches.</p>
<p>Qu&rsquo;en pensez-vous ? </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Auteur : Etienne ZINZINDOHOUE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Live Monitor : Realtime SQL and System performance data</title>
		<link>https://blog.developpez.com/zinzineti/p9190/sql-server-2005/sql_live_monitor_realtime_sql_and_system</link>
		<comments>https://blog.developpez.com/zinzineti/p9190/sql-server-2005/sql_live_monitor_realtime_sql_and_system#comments</comments>
		<pubDate>Tue, 10 Aug 2010 16:40:23 +0000</pubDate>
		<dc:creator><![CDATA[zinzineti]]></dc:creator>
				<category><![CDATA[OUTILS]]></category>
		<category><![CDATA[SQL SERVER 2005]]></category>
		<category><![CDATA[SQL SERVER 2008]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[SQL Live Monitor est une application .NET qui permet : &#8211;> le monitoring temps réel d&#8217;une instance SQL Qerver &#8211;> la collecte des indicateurs de performances &#8211;> la génération de fichiers CSV ou BLG (pour une analyse offline des performances dans l&#8217;outil PAL par exemple) &#8211;> l&#8217;obtention des requêtes les plus consommatrices de ressources (CPU,IO,Mémoire) &#8211;> l&#8217;obtention des Locks &#8211;> &#8230;. Et tout ceci sans aucune installation Je vous laisse découvrir le reste http://sqlmonitor.codeplex.com/]]></description>
				<content:encoded><![CDATA[<p>SQL Live Monitor est une application .NET qui permet :<br />
 &#8211;> le monitoring temps réel d&rsquo;une instance SQL Qerver<br />
 &#8211;> la collecte des indicateurs de performances<br />
 &#8211;> la génération de fichiers CSV ou BLG (pour une analyse offline des performances dans l&rsquo;outil <strong>PAL</strong> par exemple)<br />
 &#8211;> l&rsquo;obtention des requêtes les plus consommatrices de ressources (CPU,IO,Mémoire)<br />
 &#8211;> l&rsquo;obtention des Locks<br />
 &#8211;> &#8230;.<br />
<span id="more-112"></span><br />
<strong>Et tout ceci sans aucune installation</strong><br />
Je vous laisse découvrir le reste <a href="http://sqlmonitor.codeplex.com/">http://sqlmonitor.codeplex.com/</a></p>
<table style="width:auto;">
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/WcCQVDnBYcHUzefrNJeEsA?feat=embedwebsite"><img src="http://lh3.ggpht.com/_V0OXnmvK0ec/TGFuSyh6MbI/AAAAAAAAATg/3HMW9Qv5bZ8/s800/SQL%20Live%20Monitor.jpg" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif; font-size:11px; text-align:right">
</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
