r10311@llin: dpavlin | 2006-03-07 15:00:12 +0100
[BackupPC.git] / sql / zz_dst_files_fix.sql
1 drop index dst_i1 ;
2 drop index dst_i2 ;
3 drop index dst_i3 ;
4 drop table dst_files_ids ;
5 drop table dst_files ;
6
7
8 select hostid,shareid,num,abstime(date),size,inc_size into dst_files from backups where date > abstime('2005-10-24')::int order by abstime,hostid,num;
9
10 delete from archive_backup where backup_id in (select id from backups where date > abstime('2005-10-24')::int) ;
11 delete from backups where date > abstime('2005-10-24')::int;
12 vacuum analyze backups;
13
14 create index dst_i1 on dst_files(shareid) ;
15 create index dst_i2 on dst_files(num) ;
16 vacuum analyze dst_files ;
17 create index dst_i3 on files(backupnum) ;
18 vacuum analyze files ;
19
20 select id into dst_files_ids from files inner join dst_files on dst_files.shareid = files.shareid and dst_files.num = files.backupnum ;
21 create unique index dst_i4 on dst_files_ids(id) ;
22 vacuum analyze dst_files_ids ;
23
24 delete from files where id in (select id from dst_files_ids) ;
25
26 vacuum full analyze verbose files ;
27
28 drop table dst_files_ids ;
29 drop table dst_files ;
30
31 drop index dst_i3 ;