algorand / indexer

searchable history and current state

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requests with after/before-time have unpredictable postgres query plans.

urtho opened this issue · comments

Problem

Queries with after/before-time have unpredictable performance due to Postgres optimizer issues with joins with block_header table.
Postgres 14 appears to create even worse performing query plans then PG13 when joining over large time ranges with block header table.

Solution

Avoid block_header joins by converting the after/before-time requests to min/max-round requests - eg by using CTE to establish the round number boundaries first.

Urgency

Requests with after/before-time parameters basically do not work at Algonode due to a lot of extra indexes and bad planner guesses even with extended stats.