From 7509e5aa6630ceca20e1ba0b9f332e05a0228112 Mon Sep 17 00:00:00 2001 From: Dorian Hoxha Date: Tue, 27 Feb 2024 09:54:04 +0100 Subject: [PATCH 1/2] Change `Cache_tag_rowid` to a partial index because we don't need to query rows efficiently `where tag IS NULL` --- diskcache/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diskcache/core.py b/diskcache/core.py index ad9ad4c..eb30753 100644 --- a/diskcache/core.py +++ b/diskcache/core.py @@ -2028,7 +2028,8 @@ def create_tag_index(self): """ sql = self._sql - sql('CREATE INDEX IF NOT EXISTS Cache_tag_rowid ON Cache(tag, rowid)') + sql('CREATE INDEX IF NOT EXISTS Cache_tag_rowid ON Cache(tag, rowid) ' + 'WHERE tag IS NOT NULL') self.reset('tag_index', 1) def drop_tag_index(self): From db6492e5bf5ad0a06650cf505f1e27a27ece13c5 Mon Sep 17 00:00:00 2001 From: Dorian Hoxha Date: Tue, 27 Feb 2024 09:57:46 +0100 Subject: [PATCH 2/2] Fix formatting --- diskcache/core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/diskcache/core.py b/diskcache/core.py index eb30753..7a3d23b 100644 --- a/diskcache/core.py +++ b/diskcache/core.py @@ -2028,8 +2028,10 @@ def create_tag_index(self): """ sql = self._sql - sql('CREATE INDEX IF NOT EXISTS Cache_tag_rowid ON Cache(tag, rowid) ' - 'WHERE tag IS NOT NULL') + sql( + 'CREATE INDEX IF NOT EXISTS Cache_tag_rowid ON Cache(tag, rowid) ' + 'WHERE tag IS NOT NULL' + ) self.reset('tag_index', 1) def drop_tag_index(self):