Skip to content

Commit

Permalink
⚡️ (cdviz-db) add indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidB committed Apr 1, 2024
1 parent c9f8157 commit 70b747a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cdviz-db/migrations/20240401171152.sql
Original file line number Diff line number Diff line change
@@ -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';
3 changes: 2 additions & 1 deletion cdviz-db/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
h1:iMxNr2Ku/G2PcNz5GvMGn9GSNPBbHpZZGqb5ZnXohJY=
h1:G8sqtBxbE8rQ0ZReTiVO01ugCUK0Z5U1/tn0i10a0H4=
20240316184734.sql h1:P4X1rAK3TUnBFjHwTZw+Lc7l3x9qkKXmTk8Y56GjMvI=
20240401171152.sql h1:Oh6ZIUfdo8j/LCUmA+YWmv28MIJYKsioxYIAOSA2MhI=
4 changes: 4 additions & 0 deletions cdviz-db/src/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 $$
Expand Down

0 comments on commit 70b747a

Please sign in to comment.