Skip to content

Add indexes#67

Merged
DOBEN merged 1 commit intomainfrom
new-indexes
Mar 11, 2026
Merged

Add indexes#67
DOBEN merged 1 commit intomainfrom
new-indexes

Conversation

@DOBEN
Copy link
Copy Markdown
Member

@DOBEN DOBEN commented Mar 11, 2026

Purpose

Related to: Concordium/concordium-wallet-proxy#174

Optimized queries of the form:

SELECT "ati"."id", "ati"."account", "ati"."summary", "summaries"."id", "summaries"."block", "summaries"."timestamp", "summaries"."height", "summaries"."summary"
FROM "ati" INNER JOIN "summaries" ON "ati"."summary" = "summaries"."id"
WHERE ("ati"."account" = decode('12717900048886D2FE34C5042C3C127B6C11E321A4C1A95B572D3D12508EDE0B', 'hex')) AND ("summaries"."height" >= 43619225)
ORDER BY "ati"."id" ASC

When the range of blocks is small the indexes are used. For very large ranges, the query plan still uses a Parallel Seq Scan with an account that has a lot of summaries.

Screenshot from 2026-03-11 09-40-22-1

Changes

  • Add indexes to optimize fetching summaries for a specific account and filtering entries by block height or timestamp.
  • Add indexe to optimize fetching summaries for a specific account and efficient ordering by row id.

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

CLA acceptance

_Remove if not applicable.

By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0

@DOBEN DOBEN merged commit 4774f70 into main Mar 11, 2026
3 checks passed
@DOBEN DOBEN deleted the new-indexes branch March 11, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants