From 31fc898d56e7af32dec815610f374e0c6032671c Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 29 Sep 2025 19:07:54 +0000 Subject: [PATCH] Index the FOLLOWS table --- db/schemas/sokwedb/indexes/Makefile | 3 +- db/schemas/sokwedb/indexes/create/follows.m4 | 30 ++++++++++++++++++++ db/schemas/sokwedb/indexes/drop/follows.m4 | 28 ++++++++++++++++++ doc/src/tables/follows.m4 | 2 ++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 db/schemas/sokwedb/indexes/create/follows.m4 create mode 100644 db/schemas/sokwedb/indexes/drop/follows.m4 diff --git a/db/schemas/sokwedb/indexes/Makefile b/db/schemas/sokwedb/indexes/Makefile index 69a2a0b..a46675f 100644 --- a/db/schemas/sokwedb/indexes/Makefile +++ b/db/schemas/sokwedb/indexes/Makefile @@ -19,7 +19,8 @@ # This determines the order in which the indexes are put into the database. # This is not really important but is needed for other types of db objects. -ORDER := biography_data biography_log comm_membs comm_memb_log +ORDER := biography_data biography_log comm_membs comm_memb_log \ + follows ## ## CAUTION: This Makefile is not designed to be run directly. It is normally diff --git a/db/schemas/sokwedb/indexes/create/follows.m4 b/db/schemas/sokwedb/indexes/create/follows.m4 new file mode 100644 index 0000000..7602998 --- /dev/null +++ b/db/schemas/sokwedb/indexes/create/follows.m4 @@ -0,0 +1,30 @@ +dnl Copyright (C) 2025 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + +CREATE UNIQUE INDEX IF NOT EXISTS follows_date_focal ON follows + (date, focal); + +CREATE INDEX IF NOT EXISTS follows_focal ON follows + (focal); +CREATE INDEX IF NOT EXISTS follows_community ON follows + (community); diff --git a/db/schemas/sokwedb/indexes/drop/follows.m4 b/db/schemas/sokwedb/indexes/drop/follows.m4 new file mode 100644 index 0000000..235b0c8 --- /dev/null +++ b/db/schemas/sokwedb/indexes/drop/follows.m4 @@ -0,0 +1,28 @@ +dnl Copyright (C) 2025 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +DROP INDEX IF EXISTS follows_date_focal; + +DROP INDEX IF EXISTS follows_focal; +DROP INDEX IF EXISTS follows_community; diff --git a/doc/src/tables/follows.m4 b/doc/src/tables/follows.m4 index d65140b..431830c 100644 --- a/doc/src/tables/follows.m4 +++ b/doc/src/tables/follows.m4 @@ -31,6 +31,8 @@ FOLLOWS |FOLLOWS_summary| A scheduled follow may or may not have any related observations, related |EVENTS| rows. +The combination of |FOLLOWS.Focal| and |FOLLOWS.Date| must be unique. + .. Comment out until ARRIVALS exists The system will generate a warning when a FOLLOWS row does not have a |ARRIVALS| related row that records the presence of the focal, -- 2.34.1