From ace0150ac2c1dce6512e495281480c77475b5cb8 Mon Sep 17 00:00:00 2001 From: Matvey Arye Date: Fri, 27 Oct 2023 13:01:07 -0400 Subject: [PATCH] Add id index to the work queue table Needed to efficiently delete ids during processing. --- nbs/01_pgvectorizer.ipynb | 2 ++ timescale_vector/pgvectorizer.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/nbs/01_pgvectorizer.ipynb b/nbs/01_pgvectorizer.ipynb index 4d88b62..f77abc8 100644 --- a/nbs/01_pgvectorizer.ipynb +++ b/nbs/01_pgvectorizer.ipynb @@ -87,6 +87,8 @@ " id int\n", " );\n", "\n", + " CREATE INDEX ON {self.schema_name}.{self.work_queue_table_name}(id);\n", + "\n", " CREATE OR REPLACE FUNCTION {self.schema_name}.{self.trigger_name_fn}() RETURNS TRIGGER LANGUAGE PLPGSQL AS $$ \n", " BEGIN \n", " IF (TG_OP = 'DELETE') THEN\n", diff --git a/timescale_vector/pgvectorizer.py b/timescale_vector/pgvectorizer.py index 147cc15..1cb97e6 100644 --- a/timescale_vector/pgvectorizer.py +++ b/timescale_vector/pgvectorizer.py @@ -60,6 +60,8 @@ def register(self): id int ); + CREATE INDEX ON {self.schema_name}.{self.work_queue_table_name}(id); + CREATE OR REPLACE FUNCTION {self.schema_name}.{self.trigger_name_fn}() RETURNS TRIGGER LANGUAGE PLPGSQL AS $$ BEGIN IF (TG_OP = 'DELETE') THEN