OpenMetadata/bootstrap/sql/migrations/native/1.12.1/postgres/schemaChanges.sql
Sriharsha Chintalapani 7465810fdd
Audit Log performance improvements (#26023)
* Audit Log performance improvements

* Audit Log performance improvements

* Address comments

* removed fixme from audit log tests

---------

Co-authored-by: Rohit0301 <rj03012002@gmail.com>
Co-authored-by: Rohit Jain <60229265+Rohit0301@users.noreply.github.com>
2026-02-26 12:15:39 +05:30

9 lines
684 B
SQL

-- Add search_text column for full-text search on audit log events.
-- Populated at write time with searchable content extracted from the change event
-- (user name, entity FQN, entity type, service name, field change names and values).
-- This avoids scanning the event_json TEXT column at query time.
ALTER TABLE audit_log_event ADD COLUMN IF NOT EXISTS search_text TEXT DEFAULT NULL;
-- PostgreSQL built-in GIN index on tsvector expression — no extensions required.
-- Supports to_tsvector() @@ plainto_tsquery() queries for full-text search.
CREATE INDEX IF NOT EXISTS idx_audit_log_search_text ON audit_log_event USING GIN (to_tsvector('english', coalesce(search_text, '')));