Commit e0e1335ea465744fce1657dd9df1fb5839b02334

Authored by Starlone Passos
1 parent d585ea84

Indicador 15 e 03 - tamanho tabelas e database - Correcao para SQL Server

Showing 1 changed file with 7 additions and 2 deletions   Show diff stats
rn/MdEstatisticasColetarRN.php
... ... @@ -252,7 +252,7 @@ class MdEstatisticasColetarRN extends InfraRN {
252 252 if ($sgbd == 'MySql') {
253 253 $query = "SELECT table_schema, SUM(data_length + index_length) as tamanho FROM information_schema.TABLES WHERE table_schema = 'sei' GROUP BY table_schema";
254 254 } elseif ($sgbd == 'SqlServer') {
255   - $query = "SELECT 'a' as table_schema, 1 as tamanho";
  255 + $query = "SELECT SUM(Total_Pages * 8 * 1000) As tamanho FROM sys.partitions As P INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id INNER JOIN sys.tables t on t.object_id = p.object_id";
256 256 }
257 257 $rs = BancoSEI::getInstance()->consultarSql($query);
258 258 $tamanho = (count($rs) && isset($rs[0]['tamanho'])) ? $rs[0]['tamanho'] : 0;
... ... @@ -267,7 +267,12 @@ class MdEstatisticasColetarRN extends InfraRN {
267 267 if ($sgbd == 'MySql') {
268 268 $query = "SELECT table_name as tabela, data_length + index_length as tamanho FROM information_schema.TABLES WHERE table_schema = 'sei'";
269 269 } elseif ($sgbd == 'SqlServer') {
270   - $query = "SELECT OBJECT_NAME(object_id) As tabela, SUM(Total_Pages * 8 * 1000) As tamanho FROM sys.partitions As P INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id GROUP BY OBJECT_NAME(object_id) ORDER BY tabela";
  270 + $query = "" .
  271 + " SELECT t.name as tabela, SUM(Total_Pages * 8 * 1000) As tamanho " .
  272 + " FROM sys.partitions As P " .
  273 + " INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id " .
  274 + " INNER JOIN sys.tables t on t.object_id = p.object_id " .
  275 + " GROUP BY t.name ORDER BY t.name";
271 276 }
272 277 $tabelas = BancoSEI::getInstance()->consultarSql($query);
273 278  
... ...