Skip to content

add tag indexes - #593

Open
pjfanning wants to merge 4 commits into
apache:mainfrom
pjfanning:ddl
Open

add tag indexes#593
pjfanning wants to merge 4 commits into
apache:mainfrom
pjfanning:ddl

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Issue 1: Missing Tag-Leading Index on event_tag Table

Problem: The event_tag PK is (persistence_id, sequence_number, tag) — tag is the 3rd column. eventsByTag queries filter on tag first, so the PK index can't be used efficiently.

Fix: Added event_tag_idx index on the tag column across all 6 database dialects:

│ postgres/postgres-create-schema.sql │ CREATE INDEX CONCURRENTLY event_tag_idx on public.event_tag(tag) │
│ mysql/mysql-create-schema.sql │ CREATE INDEX event_tag_idx on event_tag (tag) │
│ mariadb/mariadb-create-schema.sql │ CREATE INDEX event_tag_idx on event_tag (tag) │
│ oracle/oracle-create-schema.sql │ CREATE INDEX EVENT_TAG_IDX ON EVENT_TAG (TAG) │
│ sqlserver/sqlserver-create-schema.sql │ CREATE INDEX event_tag_idx on event_tag (tag) │
│ h2/h2-create-schema.sql │ CREATE INDEX IF NOT EXISTS "event_tag_idx" on PUBLIC."event_tag" ("tag") │

Scala/Slick: Added val tagIdx = index(...) in JournalTables.scala:123

Migration scripts (for existing databases):

  • postgres/postgresql-event-tag-index-migration.sql
  • mysql/mysql-event-tag-index-migration.sql
  • mariadb/migration-2.0.0/mariadb-event-tag-index-migration.sql
  • oracle/migration-2.0.0/oracle-event-tag-index-migration.sql
  • sqlserver/sqlserver-event-tag-index-migration.sql

Issue 2: Missing global_offset Index in Oracle durable_state DDL

Problem: PostgreSQL, MySQL, MariaDB, H2, and SQL Server all had state_global_offset_idx — Oracle was the only dialect missing it.

Fix:

  • oracle/oracle-create-schema.sql: Added CREATE INDEX STATE_GLOBAL_OFFSET_IDX ON DURABLE_STATE (GLOBAL_OFFSET)
  • Also included in oracle/migration-2.0.0/oracle-event-tag-index-migration.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant