![]() |
#3 |
Участник
|
Цитата:
Сообщение от mazzy
![]() Думаю, что и первый и второй вариант примерно одинаковы по сути. А второй выполнить быстрее и проще. Только смотреть не на прирост базы, а на прирост таблиц.
Для начала посмотреть какие таблицы являются самыми прожорливыми (в QA выполнить команду dbcc contig with tableresults) Сравнить с бэкапом месячной давности. Вычеркнуть таблицы-логи. На каком-то буржуйском сайте нашел в свое время скрипт для определения размеров таблиц. Вот его немного доработанная версия (размеры выводятся в kb, отсортированные по убыванию): Код: set nocount on /* DATABASE TABLE SPY SCRIPT Micheal Soelter 1/24/03 DESCRIPTION returns table size information SORTING USAGE @sort bit values 0 = alphabetically by table name 1 = sorted by total space used by table */ declare @cmdstr varchar(100) declare @sort bit select @sort = 1 /* edit this value for sorting options */ /* DO NOT EDIT ANY CODE BELOW THIS LINE */ --create temporary table if object_id('tempdb..#temptable') is not null drop table #temptable create table #temptable ( table_name varchar(100), row_count int, table_size_str char(15), data_space_used_str char(15), idx_space_used_str char(15), unused_space_str char(15), table_size int, data_space_used int, idx_space_used int, unused_space int ) --create stored procedure string select @cmdstr = 'sp_msforeachtable ''sp_spaceused "?"''' --populate tempoary table insert into #temptable (table_name, row_count, table_size_str, data_space_used_str, idx_space_used_str, unused_space_str) exec(@cmdstr) --determine sorting method update #temptable set table_size = cast(replace(table_size_str, ' KB', '') as int), data_space_used = cast(replace(data_space_used_str, ' KB', '') as int), idx_space_used = cast(replace(idx_space_used_str, ' KB', '') as int), unused_space = cast(replace(unused_space_str, ' KB', '') as int) if @sort = 0 begin --retrieve table data and sort alphabetically select table_name, row_count, table_size, data_space_used, idx_space_used, unused_space from #temptable order by table_name end else begin --retrieve table data and sort by the size of the table select table_name, row_count, table_size, data_space_used, idx_space_used, unused_space from #temptable order by table_size desc end --delete temporay table drop table #temptable |
|