-
Notifications
You must be signed in to change notification settings - Fork 8
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
Modify account search with bounded scan mechanics #121
Conversation
I've just tested this PR with the following requests: Unbounded requests
Bounded requests
|
Here's an example of how the bounded scan machinery protects the server:
Note that it takes ~2 seconds and there's no
It takes roughly as much as the other queries, and it has a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR extends the
/txs/account
endpoint by applying theBoundedScan
machinery to it. This way, when theChainweb-Execution-Strategy: Bounded
header is passed to it, it will only scan up to a predetermined number of rows in the database, just like the/txs/events
and/txs/search
endpoints.Note that under normal circumstances, the bounded scan should be unnoticeable for the client of the
/txs/account
endpoint, because unlike the search endpoints (/txs/{events,search}
),/txs/account
fetches is results almost directly from the respectiveaccount,height
indexes. However, it still applies some extra conditions that aren't directly on the indexes (such as the token type and the optional chain ID predicates). For the vast majority of the practical cases, these predicates shouldn't filter out enough rows to make the bounded scan query produce less rows than thelimit
, that's why we're currently not trying to address this concern by extending our indexes (and incurring other costs). So, having the bounded scan machinery under this endpoint makes sure that specifically crafted/txs/account
queries can't hit various corner cases that make the server do a lot of work per request.