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