diff options
author | David Baker <dave@matrix.org> | 2017-10-02 16:20:41 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2017-10-02 16:20:41 +0100 |
commit | 27955056e092b440ed00da13fe6326dd438bb900 (patch) | |
tree | 8480cf26404b89993e6ffa6cadbabc477be19661 /synapse/storage/schema/delta | |
parent | Merge pull request #2472 from matrix-org/erikj/groups_rooms (diff) | |
parent | Merge pull request #2480 from matrix-org/rav/federation_client_logging (diff) | |
download | synapse-27955056e092b440ed00da13fe6326dd438bb900.tar.xz |
Merge branch 'develop' into erikj/groups_merged
Diffstat (limited to 'synapse/storage/schema/delta')
-rw-r--r-- | synapse/storage/schema/delta/44/expire_url_cache.sql | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/synapse/storage/schema/delta/44/expire_url_cache.sql b/synapse/storage/schema/delta/44/expire_url_cache.sql new file mode 100644 index 0000000000..e2b775f038 --- /dev/null +++ b/synapse/storage/schema/delta/44/expire_url_cache.sql @@ -0,0 +1,38 @@ +/* Copyright 2017 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +CREATE INDEX local_media_repository_url_idx ON local_media_repository(created_ts) WHERE url_cache IS NOT NULL; + +-- we need to change `expires` to `expires_ts` so that we can index on it. SQLite doesn't support +-- indices on expressions until 3.9. +CREATE TABLE local_media_repository_url_cache_new( + url TEXT, + response_code INTEGER, + etag TEXT, + expires_ts BIGINT, + og TEXT, + media_id TEXT, + download_ts BIGINT +); + +INSERT INTO local_media_repository_url_cache_new + SELECT url, response_code, etag, expires + download_ts, og, media_id, download_ts FROM local_media_repository_url_cache; + +DROP TABLE local_media_repository_url_cache; +ALTER TABLE local_media_repository_url_cache_new RENAME TO local_media_repository_url_cache; + +CREATE INDEX local_media_repository_url_cache_expires_idx ON local_media_repository_url_cache(expires_ts); +CREATE INDEX local_media_repository_url_cache_by_url_download_ts ON local_media_repository_url_cache(url, download_ts); +CREATE INDEX local_media_repository_url_cache_media_idx ON local_media_repository_url_cache(media_id); |