]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: create indexes to speed up grooming
authorJosef Cejka <jcejka@suse.de>
Fri, 29 Jul 2022 16:05:05 +0000 (12:05 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Fri, 29 Jul 2022 16:05:05 +0000 (12:05 -0400)
Create indexes on _r_de and _f_de tables
to speed up delete operations called by groom() function.

Primary keys of those tables are optimalized to search rows
by buildids so delete by file and mtime attributes
has to scan the whole table. On large database can single
delete query take minutes and grooming will be aborted
before completion by time limit.

New indexes are compatible with current sqlite schema.

Signed-off-by: Josef Cejka <jcejka@suse.de>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx

index 029687fff9015659332dbb4c10a5ab8bde3465ea..2ff63e22feb8d609a045a49dca721498a33e4def 100644 (file)
@@ -1,3 +1,7 @@
+2022-07-29  Josef Cejka <jcejka@suse.de>
+
+       * debuginfod.cxx: Create db indexes for fast delete while grooming.
+
 2022-06-03  Michael Trapp <michael.trapp@sap.com>
 
        * debuginfod.cxx (scan_source_info): New global.
index 51f4302ba37dea33d9d388c341e3a2347eebc5b0..303ffe00c272db17c4671f80ccbf1a56377f9f53 100644 (file)
@@ -174,6 +174,8 @@ static const char DEBUGINFOD_SQLITE_DDL[] =
   "        foreign key (buildid) references " BUILDIDS "_buildids(id) on update cascade on delete cascade,\n"
   "        primary key (buildid, file, mtime)\n"
   "        ) " WITHOUT_ROWID ";\n"
+  // Index for faster delete by file identifier
+  "create index if not exists " BUILDIDS "_f_de_idx on " BUILDIDS "_f_de (file, mtime);\n"
   "create table if not exists " BUILDIDS "_f_s (\n"
   "        buildid integer not null,\n"
   "        artifactsrc integer not null,\n"
@@ -196,6 +198,8 @@ static const char DEBUGINFOD_SQLITE_DDL[] =
   "        foreign key (buildid) references " BUILDIDS "_buildids(id) on update cascade on delete cascade,\n"
   "        primary key (buildid, debuginfo_p, executable_p, file, content, mtime)\n"
   "        ) " WITHOUT_ROWID ";\n"
+  // Index for faster delete by archive file identifier
+  "create index if not exists " BUILDIDS "_r_de_idx on " BUILDIDS "_r_de (file, mtime);\n"
   "create table if not exists " BUILDIDS "_r_sref (\n" // outgoing dwarf sourcefile references from rpm
   "        buildid integer not null,\n"
   "        artifactsrc integer not null,\n"