We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Next token is ignored in some CTEs causing full table scans during pagination.
This patch shows x5 speedup in average query exec time. Not an ultimate solution but a quick win.
--- a/idb/postgres/postgres.go +++ b/idb/postgres/postgres.go @@ -1797,13 +1797,25 @@ func (db *IndexerDb) buildAccountQuery(opts idb.AccountQueryOptions, countOnly b whereArgs = append(whereArgs, *opts.AssetLT) partNumber++ } + if len(opts.GreaterThanAddress) > 0 { + aq += fmt.Sprintf(" AND addr > $%d", partNumber) + whereArgs = append(whereArgs, opts.GreaterThanAddress) + partNumber++ + } aq = "qasf AS (" + aq + ")" withClauses = append(withClauses, aq) } if opts.HasAppID != 0 { - withClauses = append(withClauses, fmt.Sprintf("qapf AS (SELECT addr FROM account_app WHERE app = $%d)", partNumber)) + aq := fmt.Sprintf("SELECT addr FROM account_app WHERE app = $%d", partNumber) whereArgs = append(whereArgs, opts.HasAppID) partNumber++ + if len(opts.GreaterThanAddress) > 0 { + aq += fmt.Sprintf(" AND addr > $%d", partNumber) + whereArgs = append(whereArgs, opts.GreaterThanAddress) + partNumber++ + } + aq = "qapf AS (" + aq + ")" + withClauses = append(withClauses, aq)
The text was updated successfully, but these errors were encountered:
Addressed in #1615 - thanks @urtho !
Sorry, something went wrong.
No branches or pull requests
Problem
Next token is ignored in some CTEs causing full table scans during pagination.
Solution
This patch shows x5 speedup in average query exec time.
Not an ultimate solution but a quick win.
The text was updated successfully, but these errors were encountered: