From ebbbf7ecea263face8ee28b7f29a2ee7e9c54e64 Mon Sep 17 00:00:00 2001 From: sunnavy Date: Fri, 15 Dec 2023 06:51:21 -0500 Subject: [PATCH] Set id as the PRIMARY KEY of AttachmentsIndex for Pg This is consistent with mysql's fulltext table. As id is the primary key, DB automatically indexes the column which helps performance especially for the following SQL that is called quite frequently when indexing data: SELECT MAX(id) FROM AttachmentsIndex --- etc/upgrade/5.0.6/schema.Pg | 2 ++ sbin/rt-setup-fulltext-index.in | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 etc/upgrade/5.0.6/schema.Pg diff --git a/etc/upgrade/5.0.6/schema.Pg b/etc/upgrade/5.0.6/schema.Pg new file mode 100644 index 00000000000..49f28588c08 --- /dev/null +++ b/etc/upgrade/5.0.6/schema.Pg @@ -0,0 +1,2 @@ +ALTER TABLE IF EXISTS AttachmentsIndex DROP CONSTRAINT IF EXISTS attachmentsindex_pkey; +ALTER TABLE IF EXISTS AttachmentsIndex ADD PRIMARY KEY(id); diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in index 4e75e7eda72..d079ab40926 100644 --- a/sbin/rt-setup-fulltext-index.in +++ b/sbin/rt-setup-fulltext-index.in @@ -327,7 +327,8 @@ elsif ( $DB{'type'} eq 'Pg' ) { push @schema, split /;\n+/, <