summaryrefslogtreecommitdiff
path: root/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2022-07-20 11:53:27 -0400
committerThomas Markwalder <tmark@isc.org>2022-07-22 10:13:55 -0400
commitb0c3dda963425f5d7dbb97bbce4e83d453b2f859 (patch)
treeb8b70c549d911ffd09c7d2f7c4d79ed26e5f9a5c /src/share/database/scripts/pgsql/dhcpdb_create.pgsql
parent9e6740b5c124e62a78d7bedceddcff3cb26289d8 (diff)
[#2452] Improve postgresl indexes on hosts table
src/share/database/scripts/pgsql/dhcpdb_create.pgsql src/share/database/scripts/pgsql/upgrade_012_to_013.sh.in Added host index for dhcp identifier + type only - v4 and v6 Modified existing host index to include subnet-id = 0 - v4 and v6
Diffstat (limited to 'src/share/database/scripts/pgsql/dhcpdb_create.pgsql')
-rw-r--r--src/share/database/scripts/pgsql/dhcpdb_create.pgsql18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
index a3d246dfd8..7c1ce31870 100644
--- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
+++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
@@ -5604,6 +5604,24 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
+-- Improve hosts indexes for better performance of global reservations
+-- Create new index that uses only dhcp4_identifier.
+CREATE INDEX key_dhcp4_identifier on hosts (dhcp_identifier, dhcp_identifier_type);
+-- Create new index that uses only dhcp4_identifier.
+CREATE INDEX key_dhcp6_identifier on hosts (dhcp_identifier, dhcp_identifier_type);
+
+-- Modify existing indexes to include subnet_id values of 0, so index is also used
+-- for global reservations.
+DROP INDEX key_dhcp4_identifier_subnet_id;
+CREATE UNIQUE INDEX key_dhcp4_identifier_subnet_id ON hosts
+ (dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp4_subnet_id ASC)
+ WHERE (dhcp4_subnet_id IS NOT NULL);
+
+DROP INDEX key_dhcp6_identifier_subnet_id;
+CREATE UNIQUE INDEX key_dhcp6_identifier_subnet_id ON hosts
+ (dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp6_subnet_id ASC)
+ WHERE (dhcp6_subnet_id IS NOT NULL);
+
-- Update the schema version number.
UPDATE schema_version
SET version = '13', minor = '0';