Add missing index for voter filtering in witness votes history

Summary

Add index on (witness_id, voter_id) to hafbe_app.witness_votes_history table for efficient voter filtering in the get_witness_votes_history endpoint.

Problem

The endpoint was timing out (HTTP 500) when filtering by voter-name parameter because the query had to scan all records for a witness to find matches. This was exposed by the NFS cache migration which slightly increased query latency.

Solution

Add a composite B-tree index witness_votes_history_witness_voter that enables efficient lookups when filtering by both witness and voter.

Test plan

  • get_witness_votes_history endpoint with voter filter no longer times out
  • All pattern tests pass

Merge request reports

Loading