Changes between Initial Version and Version 1 of PartitioningVerification


Ignore:
Timestamp:
02/08/26 16:28:53 (3 weeks ago)
Author:
185022
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PartitioningVerification

    v1 v1  
     1= Верификација
     2
     3Проверката е слична за сите табели.
     4
     5Подолу е прикажан пример само за `encounters` табелата.
     6
     7== Проверка дека датотечните групи се креирани исправно
     8
     9{{{#!sql
     10select
     11    fg.name as FilegroupName,
     12    df.name as LogicalFileName,
     13    df.type_desc as FileType,
     14    df.physical_name as PhysicalPath,
     15    df.size / 128.0 as SizeMB
     16from sys.filegroups fg
     17left join sys.database_files df ON fg.data_space_id = df.data_space_id
     18order by fg.name;
     19go
     20}}}
     21
     22== Проверка дека партициската шема и функцијата работат исправно
     23
     24{{{#!sql
     25select
     26    ps.name as PartitionScheme,
     27    pf.name as PartitionFunction,
     28    dds.destination_id as PartitionNumber,
     29    fg.name as FilegroupName,
     30    prv.value as UpperBoundaryValue
     31from sys.partition_schemes ps
     32join sys.partition_functions pf on ps.function_id = pf.function_id
     33join sys.destination_data_spaces dds on ps.data_space_id = dds.partition_scheme_id
     34join sys.filegroups fg on dds.data_space_id = fg.data_space_id
     35left join sys.partition_range_values prv
     36    on pf.function_id = prv.function_id
     37    and dds.destination_id = case when pf.boundary_value_on_right = 1 then prv.boundary_id + 1 else prv.boundary_id end
     38where ps.name = 'ps_Encounters_Year'
     39order by dds.destination_id;
     40go
     41-----------------------------
     42select
     43    fg.name as FilegroupName,
     44    df.name as LogicalFileName,
     45    df.physical_name,
     46    df.size / 128.0 as SizeMB
     47from sys.filegroups fg
     48    left join sys.database_files df on fg.data_space_id = df.data_space_id;
     49go
     50}}}
     51
     52== Дистрибуција по партиции
     53
     54{{{#!sql
     55select
     56    $partition.pf_Encounters_Year([start]) as PartitionNumber,
     57    count(*) as 'RowCount',
     58    min([start]) as MinDate,
     59    max([start]) as MaxDate
     60from dbo.encounters
     61group by $partition.pf_Encounters_Year([start])
     62order by PartitionNumber;
     63go
     64}}}
     65
     66== Filegroup usage
     67
     68{{{#!sql
     69select
     70    fg.name as FilegroupName,
     71    count(*) as PartitionCount
     72from sys.partitions p
     73join sys.indexes i on p.object_id = i.object_id and p.index_id = i.index_id
     74join sys.data_spaces ds on i.data_space_id = ds.data_space_id
     75join sys.filegroups fg on ds.data_space_id = fg.data_space_id
     76where object_name(p.object_id) = 'Encounters'
     77group by fg.name;
     78go
     79}}}
     80
     81== Partition elimination
     82
     83{{{#!sql
     84set statistics io on
     85select count(*) from encounters where [start] >= '2022-01-01';
     86set statistics io off;
     87}}}