From: Kees Monshouwer Date: Mon, 15 Jun 2020 09:54:05 +0000 (+0200) Subject: auth: gsqlite3backend: add missing indexes X-Git-Tag: dnsdist-1.5.0-rc3~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9228%2Fhead;p=thirdparty%2Fpdns.git auth: gsqlite3backend: add missing indexes Sqlite3 backend was performing terrible in environments with many updates. On a slaved root zone the performance increase was huge, 71ms -> 1ms. Since the lack of proper indexes is causing a lot of trouble in larger environments, I target this update at 4.3.1 --- diff --git a/builder-support/debian/authoritative/debian-buster/pdns-backend-sqlite3.docs b/builder-support/debian/authoritative/debian-buster/pdns-backend-sqlite3.docs index cc1d83f9de..8813ea89d9 100644 --- a/builder-support/debian/authoritative/debian-buster/pdns-backend-sqlite3.docs +++ b/builder-support/debian/authoritative/debian-buster/pdns-backend-sqlite3.docs @@ -1,6 +1,7 @@ modules/gsqlite3backend/3.4.0_to_4.0.0_schema.sqlite3.sql modules/gsqlite3backend/4.0.0_to_4.2.0_schema.sqlite3.sql modules/gsqlite3backend/4.2.0_to_4.3.0_schema.sqlite3.sql +modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql modules/gsqlite3backend/dnssec-3.x_to_3.4.0_schema.sqlite3.sql modules/gsqlite3backend/nodnssec-3.x_to_3.4.0_schema.sqlite3.sql modules/gsqlite3backend/schema.sqlite3.sql diff --git a/builder-support/debian/authoritative/debian-jessie/pdns-backend-sqlite3.docs b/builder-support/debian/authoritative/debian-jessie/pdns-backend-sqlite3.docs index cc1d83f9de..8813ea89d9 100644 --- a/builder-support/debian/authoritative/debian-jessie/pdns-backend-sqlite3.docs +++ b/builder-support/debian/authoritative/debian-jessie/pdns-backend-sqlite3.docs @@ -1,6 +1,7 @@ modules/gsqlite3backend/3.4.0_to_4.0.0_schema.sqlite3.sql modules/gsqlite3backend/4.0.0_to_4.2.0_schema.sqlite3.sql modules/gsqlite3backend/4.2.0_to_4.3.0_schema.sqlite3.sql +modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql modules/gsqlite3backend/dnssec-3.x_to_3.4.0_schema.sqlite3.sql modules/gsqlite3backend/nodnssec-3.x_to_3.4.0_schema.sqlite3.sql modules/gsqlite3backend/schema.sqlite3.sql diff --git a/builder-support/debian/authoritative/debian-stretch/pdns-backend-sqlite3.docs b/builder-support/debian/authoritative/debian-stretch/pdns-backend-sqlite3.docs index cc1d83f9de..8813ea89d9 100644 --- a/builder-support/debian/authoritative/debian-stretch/pdns-backend-sqlite3.docs +++ b/builder-support/debian/authoritative/debian-stretch/pdns-backend-sqlite3.docs @@ -1,6 +1,7 @@ modules/gsqlite3backend/3.4.0_to_4.0.0_schema.sqlite3.sql modules/gsqlite3backend/4.0.0_to_4.2.0_schema.sqlite3.sql modules/gsqlite3backend/4.2.0_to_4.3.0_schema.sqlite3.sql +modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql modules/gsqlite3backend/dnssec-3.x_to_3.4.0_schema.sqlite3.sql modules/gsqlite3backend/nodnssec-3.x_to_3.4.0_schema.sqlite3.sql modules/gsqlite3backend/schema.sqlite3.sql diff --git a/builder-support/specs/pdns.spec b/builder-support/specs/pdns.spec index 92150ef774..5a78572cf9 100644 --- a/builder-support/specs/pdns.spec +++ b/builder-support/specs/pdns.spec @@ -412,6 +412,7 @@ fi %doc modules/gsqlite3backend/3.4.0_to_4.0.0_schema.sqlite3.sql %doc modules/gsqlite3backend/4.0.0_to_4.2.0_schema.sqlite3.sql %doc modules/gsqlite3backend/4.2.0_to_4.3.0_schema.sqlite3.sql +%doc modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql %{_libdir}/%{name}/libgsqlite3backend.so %if 0%{?rhel} >= 7 diff --git a/modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql b/modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql new file mode 100644 index 0000000000..26eb9972fc --- /dev/null +++ b/modules/gsqlite3backend/4.3.0_to_4.3.1_schema.sqlite3.sql @@ -0,0 +1,15 @@ +CREATE INDEX records_lookup_idx ON records(name, type); +CREATE INDEX records_lookup_id_idx ON records(domain_id, name, type); +CREATE INDEX records_order_idx ON records(domain_id, ordername); + +DROP INDEX IF EXISTS rec_name_index; +DROP INDEX IF EXISTS nametype_index; +DROP INDEX IF EXISTS domain_id; +DROP INDEX IF EXISTS orderindex; + +CREATE INDEX comments_idx ON comments(domain_id, name, type); + +DROP INDEX IF EXISTS comments_domain_id_index; +DROP INDEX IF EXISTS comments_nametype_index; + +ANALYZE; diff --git a/modules/gsqlite3backend/Makefile.am b/modules/gsqlite3backend/Makefile.am index 2a83677380..4c5de6dcbe 100644 --- a/modules/gsqlite3backend/Makefile.am +++ b/modules/gsqlite3backend/Makefile.am @@ -10,6 +10,7 @@ dist_doc_DATA = \ 3.4.0_to_4.0.0_schema.sqlite3.sql \ 4.0.0_to_4.2.0_schema.sqlite3.sql \ 4.2.0_to_4.3.0_schema.sqlite3.sql \ + 4.3.0_to_4.3.1_schema.sqlite3.sql \ schema.sqlite3.sql libgsqlite3backend_la_SOURCES = gsqlite3backend.cc gsqlite3backend.hh diff --git a/modules/gsqlite3backend/schema.sqlite3.sql b/modules/gsqlite3backend/schema.sqlite3.sql index 64a7da0d20..0875521185 100644 --- a/modules/gsqlite3backend/schema.sqlite3.sql +++ b/modules/gsqlite3backend/schema.sqlite3.sql @@ -27,10 +27,9 @@ CREATE TABLE records ( FOREIGN KEY(domain_id) REFERENCES domains(id) ON DELETE CASCADE ON UPDATE CASCADE ); -CREATE INDEX rec_name_index ON records(name); -CREATE INDEX nametype_index ON records(name,type); -CREATE INDEX domain_id ON records(domain_id); -CREATE INDEX orderindex ON records(ordername); +CREATE INDEX records_lookup_idx ON records(name, type); +CREATE INDEX records_lookup_id_idx ON records(domain_id, name, type); +CREATE INDEX records_order_idx ON records(domain_id, ordername); CREATE TABLE supermasters ( @@ -53,8 +52,7 @@ CREATE TABLE comments ( FOREIGN KEY(domain_id) REFERENCES domains(id) ON DELETE CASCADE ON UPDATE CASCADE ); -CREATE INDEX comments_domain_id_index ON comments (domain_id); -CREATE INDEX comments_nametype_index ON comments (name, type); +CREATE INDEX comments_idx ON comments(domain_id, name, type); CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);