On Mon, 2026-02-16 at 17:52 +0530, yudhi s wrote:
> Regarding the composite index on (request_id, event_comment_text, created_at) 
> for
> table event_audit_log, is there any advice, which we should follow for keeping
> "date column"(like column "Created_at" here) in the indexing order (apart from
> the frequency of usage in the query)?

The rule is to first have all columns that are compared with equality, then the
others, starting with the most selective one.  Based on the condition, I guessed
that that wouldn't be your "date" column, but if it is, put it second.

> And to help the table scan of the ORDER table, should we also have "entity_id"
> added to the index along with "due_date" i.e. a composite index on 
> (entity_id,due_date)?

I don't know; you'd have to test it on your test system.
The current execution plan has no use for such an index, but adding additional
columns could

1. lead to an efficient index-only scan

2. make PostgreSQL pick an altogether different, better plan

Yours,
Laurenz Albe


Reply via email to