[PATCH] [db] Create indexes for (pkg_name, version) in suite_{sources,binaries}
These two indexes make faster joins between sources and suite_sources,
and binaries and suite_binaries, since the join key will be indexed on
both sides. The difference is particularly noticeable for the binaries,
since suite_binaries has more than half a million rows.
---
>> +CREATE INDEX suite_sources_src_ver_idx ON sources (source, source_version);
> I'm not sure about this index. Isn't it already created automatically:
> # \d sources
> [...]
> Indexes:
> "sources_pkey" PRIMARY KEY, btree (source, version)
> "sources_pkg_idx" btree (source)
> [...]
Oops, sorry, that's a typo on my patch. Should be clear from the commit
message and the index name. ;-)
The index is meant to go to suite_sources, and not sources. Fixed patch
attached, thanks for spotting! (Code reviews++)
Ciao,
db/db.sql | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/db/db.sql b/db/db.sql
index ac29183..246b070 100644
--- a/db/db.sql
+++ b/db/db.sql
@@ -304,6 +304,8 @@ CREATE TABLE suite_sources (
ON DELETE CASCADE
);
+CREATE INDEX suite_sources_src_ver_idx ON suite_sources (source, source_version);
+
COMMENT ON TABLE suite_sources IS 'Source packages contained within a suite';
COMMENT ON COLUMN suite_sources.source IS 'Source package name';
COMMENT ON COLUMN suite_sources.source_version IS 'Source package version number';
@@ -328,6 +330,8 @@ CREATE TABLE suite_binaries (
ON DELETE CASCADE
);
+CREATE INDEX suite_binaries_pkg_ver_idx ON suite_binaries (package, version);
+
COMMENT ON TABLE suite_binaries IS 'Binary packages contained within a suite';
COMMENT ON COLUMN suite_binaries.package IS 'Binary package name';
COMMENT ON COLUMN suite_binaries.version IS 'Binary package version number';
--
1.6.2.272.g44c5b
Reply to: