aboutsummaryrefslogtreecommitdiff
path: root/bpkg/database.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg/database.cxx')
-rw-r--r--bpkg/database.cxx28
1 files changed, 26 insertions, 2 deletions
diff --git a/bpkg/database.cxx b/bpkg/database.cxx
index 3d83de8..e91e668 100644
--- a/bpkg/database.cxx
+++ b/bpkg/database.cxx
@@ -55,8 +55,8 @@ namespace bpkg
// Register the data migration functions.
//
- // NOTE: remember to qualify table names with \"main\". if using native
- // statements.
+ // NOTE: remember to qualify table/index names with \"main\". if using
+ // native statements.
//
template <odb::schema_version v>
using migration_entry = odb::data_migration_entry<v, DB_SCHEMA_VERSION_BASE>;
@@ -87,6 +87,18 @@ namespace bpkg
"SET configuration = '" + sl->uuid.string () + "'");
});
+ static const migration_entry<10>
+ migrate_v10 ([] (odb::database& db)
+ {
+ // Create the multi-column index for the configuration and prerequisite
+ // columns of the selected_package_prerequisites table.
+ //
+ db.execute (
+ "CREATE INDEX "
+ "\"main\".selected_package_prerequisites_configuration_prerequisite_i "
+ "ON selected_package_prerequisites (configuration, prerequisite)");
+ });
+
static inline path
cfg_path (const dir_path& d, bool create)
{
@@ -175,6 +187,18 @@ namespace bpkg
schema_catalog::create_schema (*this);
+ // To speed up the query_dependents() function create the multi-
+ // column index for the configuration and prerequisite columns of
+ // the selected_package_prerequisites table.
+ //
+ // @@ Use ODB pragma if/when support for container indexes is added.
+ //
+ execute (
+ "CREATE INDEX "
+ "selected_package_prerequisites_configuration_prerequisite_i "
+ "ON selected_package_prerequisites (configuration, "
+ "prerequisite)");
+
persist (*create); // Also assigns link id.
// Cache the configuration information.