1
# Copyright 2008-2015 Canonical
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as
5
# published by the Free Software Foundation, either version 3 of the
6
# License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# For further info, check http://launchpad.net/filesync-server
18
"""Cleanup indexes on Object table.
20
Based on feedback from Serius, this patch drops indexes no longer used.
24
# this is used when doing magic uploads
25
# CREATE INDEX object_content_hash_fkey ON Object(content_hash)
26
# Since all queries are done using volume_id, owner_id, there is
27
# no need for this index
28
# CREATE INDEX object_owner_id_fkey ON Object(owner_id)
30
DROP INDEX object_owner_id_fkey;
32
# we don't look up nodes only by kind.
33
# CREATE INDEX object_kind ON Object (kind)
35
DROP INDEX object_kind;
37
# This index is not needed
38
# CREATE INDEX object_generation_created_idx ON object(generation_created);
40
DROP INDEX object_generation_created_idx;
42
# This index is not needed
43
# CREATE INDEX object_generation_idx ON object(generation);
45
DROP INDEX object_generation_idx;
47
# Since we are looking up files by owner_id, volume_id, status=Live,
48
# This index never gets used.
49
# CREATE INDEX object_mimtype_idx ON object(mimetype);
51
DROP INDEX object_mimtype_idx;
53
# This index is still important
54
# CREATE UNIQUE INDEX object_parent_name_uk ON object(parent_id, name)
55
# WHERE (status = 'Live'::lifecycle_status);
57
# This index is redundant based on the index above
58
#CREATE INDEX object_parent_name_volume
59
# ON object(parent_id, name, volume_id)
60
# WHERE ((status = 'Live'::lifecycle_status)
61
# AND (parent_id IS NOT NULL));
63
DROP INDEX object_parent_name_volume;
65
# This is used to get user's public files for a volume
66
# CREATE INDEX object_publicfile_idx ON object(volume_id, publicfile_id)
67
# WHERE ((kind = 'File'::object_kind)
68
# AND (status = 'Live'::lifecycle_status));
70
# This is no longer used.
71
# CREATE INDEX object_roots ON object(owner_id)
72
# WHERE ((parent_id IS NULL) AND ((name)::text = ''::text));
74
DROP INDEX object_roots;
76
# This was used when doing mass deletes of old files. we cant do this now.
77
# CREATE INDEX dead_object_last_modified_idx ON object (when_last_modified)
78
# WHERE (status = 'Dead'::lifecycle_status);
80
DROP INDEX dead_object_last_modified_idx;
86
"""Apply the patch."""