Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add txn_participation.round filter #1578

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Conversation

urtho
Copy link
Contributor

@urtho urtho commented Sep 26, 2023

Summary

A fix for inefficient round filtering when using address filter.
fixes #1577

This request translates to query:

SELECT 
	t.round, t.intra, t.txn, root.txn, t.extra, t.asset FROM txn t
  JOIN txn_participation p ON t.round = p.round AND t.intra = p.intra
  LEFT OUTER JOIN txn root ON t.round = root.round AND (t.extra->>'root-intra')::int = root.intra 
  WHERE p.addr = '\x881a335631c1aaa46ed219bce34f30fb0e35a1bd8e1490802be795d8c2a7a16b' AND t.round <= 24553246
  ORDER BY p.addr, p.round DESC, p.intra DESC LIMIT 86

This query times out on any reasonable Postgres setup.

Adding a filter on p.round makes for proper use of the txn_participation index:

SELECT 
	t.round, t.intra, t.txn, root.txn, t.extra, t.asset FROM txn t
  JOIN txn_participation p ON t.round = p.round AND t.intra = p.intra
  LEFT OUTER JOIN txn root ON t.round = root.round AND (t.extra->>'root-intra')::int = root.intra 
  WHERE p.addr = '\x881a335631c1aaa46ed219bce34f30fb0e35a1bd8e1490802be795d8c2a7a16b' AND p.round <= 24553246 AND t.round <= 24553246
  ORDER BY p.addr, p.round DESC, p.intra DESC LIMIT 86  

@CLAassistant
Copy link

CLAassistant commented Sep 26, 2023

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Merging #1578 (d5c7315) into main (0f41c6d) will decrease coverage by 0.10%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #1578      +/-   ##
==========================================
- Coverage   68.58%   68.49%   -0.10%     
==========================================
  Files          37       37              
  Lines        7417     7427      +10     
==========================================
  Hits         5087     5087              
- Misses       1903     1911       +8     
- Partials      427      429       +2     
Files Coverage Δ
idb/postgres/postgres.go 66.98% <0.00%> (-0.31%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@winder winder self-assigned this Oct 19, 2023
@winder winder merged commit 6ef871c into algorand:main Oct 19, 2023
2 checks passed
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.

Timeout iterating through account transactions
5 participants