From ccd67cdff735f460233a1cec6bce476af213b37b Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 16 Apr 2025 02:31:16 +0800 Subject: [PATCH] Add Index to PostgreSQL AGE graph storage --- lightrag/kg/postgres_impl.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index b97b63ab..b6b1dc72 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1027,6 +1027,15 @@ class PGGraphStorage(BaseGraphStorage): if self.db is None: self.db = await ClientManager.get_client() + query = """CREATE INDEX entity_id_gin_idxSELECT ON %s."base" USING gin (properties);""" % (self.graph_name) + + await self.db.execute( + query, + upsert=True, + with_age=True, + graph_name=self.graph_name, + ) + async def finalize(self): if self.db is not None: await ClientManager.release_client(self.db)