From 70b747a166f449af9c272ef455ec2690bd8c49b1 Mon Sep 17 00:00:00 2001 From: David Bernard Date: Mon, 1 Apr 2024 19:16:25 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20(cdviz-db)=20add=20indexes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cdviz-db/migrations/20240401171152.sql | 8 ++++++++ cdviz-db/migrations/atlas.sum | 3 ++- cdviz-db/src/schema.sql | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 cdviz-db/migrations/20240401171152.sql diff --git a/cdviz-db/migrations/20240401171152.sql b/cdviz-db/migrations/20240401171152.sql new file mode 100644 index 0000000..70d0b0b --- /dev/null +++ b/cdviz-db/migrations/20240401171152.sql @@ -0,0 +1,8 @@ +-- Create index "idx_subject" to table: "cdevents_lake" +CREATE INDEX "idx_subject" ON "cdevents_lake" ("subject"); +-- Create index "idx_timestamp" to table: "cdevents_lake" +CREATE INDEX "idx_timestamp" ON "cdevents_lake" ("timestamp"); +-- Set comment to column: "timestamp" on table: "cdevents_lake" +COMMENT ON COLUMN "cdevents_lake" ."timestamp" IS 'timestamp of cdevents extracted from context.timestamp in the json'; +-- Set comment to column: "version" on table: "cdevents_lake" +COMMENT ON COLUMN "cdevents_lake" ."version" IS 'the version of the suject s type, extracted from context.type. The verion number are split in 0 for major, 1 for minor, 2 for patch'; diff --git a/cdviz-db/migrations/atlas.sum b/cdviz-db/migrations/atlas.sum index 1d7941b..11431b6 100644 --- a/cdviz-db/migrations/atlas.sum +++ b/cdviz-db/migrations/atlas.sum @@ -1,2 +1,3 @@ -h1:iMxNr2Ku/G2PcNz5GvMGn9GSNPBbHpZZGqb5ZnXohJY= +h1:G8sqtBxbE8rQ0ZReTiVO01ugCUK0Z5U1/tn0i10a0H4= 20240316184734.sql h1:P4X1rAK3TUnBFjHwTZw+Lc7l3x9qkKXmTk8Y56GjMvI= +20240401171152.sql h1:Oh6ZIUfdo8j/LCUmA+YWmv28MIJYKsioxYIAOSA2MhI= diff --git a/cdviz-db/src/schema.sql b/cdviz-db/src/schema.sql index 3e91e14..87c7fcf 100644 --- a/cdviz-db/src/schema.sql +++ b/cdviz-db/src/schema.sql @@ -11,11 +11,15 @@ CREATE TABLE IF NOT EXISTS "cdevents_lake" ( COMMENT ON TABLE "cdevents_lake" IS 'table of stored cdevents without transformation'; COMMENT ON COLUMN "cdevents_lake"."imported_at" IS 'the timestamp when the cdevent was stored into the table'; +COMMENT ON COLUMN "cdevents_lake"."timestamp" IS 'timestamp of cdevents extracted from context.timestamp in the json'; COMMENT ON COLUMN "cdevents_lake"."payload" IS 'the full cdevent in json format'; COMMENT ON COLUMN "cdevents_lake"."subject" IS 'subject extracted from context.type in the json'; COMMENT ON COLUMN "cdevents_lake"."predicate" IS 'predicate of the subject, extracted from context.type in the json'; COMMENT ON COLUMN "cdevents_lake"."version" IS 'the version of the suject s type, extracted from context.type. The verion number are split in 0 for major, 1 for minor, 2 for patch'; +CREATE INDEX IF NOT EXISTS "idx_timestamp" ON "cdevents_lake"("timestamp"); +CREATE INDEX IF NOT EXISTS "idx_subject" ON "cdevents_lake"("subject"); + -- create a view based on fields in the json payload -- source: [Postgresql json column to view - Database Administrators Stack Exchange](https://dba.stackexchange.com/questions/151838/postgresql-json-column-to-view?newreg=ed0a9389843a45699bfb02559dd32038) -- DO $$