Skip to content

Connecting to PostgreSQL

Ahmed edited this page Mar 16, 2026 · 2 revisions

Connecting to PostgreSQL

To connect EventLens to your PostgreSQL event store, configure the datasource block in your eventlens.yaml.

Datasource Configuration

datasource:
  url: jdbc:postgresql://localhost:5432/eventlens_dev
  username: eventlens_ro
  password: strong_password_here
  table: eventlens_events # Your materialized view mapping

Recommended Indexes

EventLens runs read-only queries. To ensure timelines and bisects are fast, index your underlying event table correctly:

-- Lookup all events for a single aggregate, in order
CREATE INDEX IF NOT EXISTS idx_domain_events_agg_seq
  ON domain_events (aggregate_type, aggregate_id, sequence);

-- Time-based queries / live windows
CREATE INDEX IF NOT EXISTS idx_domain_events_occurred_at
  ON domain_events (occurred_at);

If you frequently filter by JSON properties, consider functional indexes:

CREATE INDEX IF NOT EXISTS idx_domain_events_status
  ON domain_events ((payload->>'status'));

Return Home

Clone this wiki locally