feat: Search pipeline run API uses pagination cursor#131
feat: Search pipeline run API uses pagination cursor#131yuechao-qin wants to merge 1 commit intoycq/search-pipeline-run-date-rangefrom
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
ec33395 to
5a5675d
Compare
1f4e7d9 to
300d652
Compare
5a5675d to
8b74a37
Compare
300d652 to
67941dd
Compare
8b74a37 to
9b0355f
Compare
67941dd to
0c95a90
Compare
0c95a90 to
325027b
Compare
9b0355f to
4c82c95
Compare
4c82c95 to
9847bfa
Compare
325027b to
9a80f91
Compare
9a80f91 to
e619fa5
Compare
9847bfa to
395dc95
Compare
395dc95 to
463dfde
Compare
463dfde to
119dadb
Compare
e152073 to
986735a
Compare
119dadb to
a9adba7
Compare
|
One small advantage of opaque next_page_token is that the filter and cursor/offset are tied together. |
|
We can decode the created_at from the id. Do we need it in the cursor? |
a9adba7 to
8d6118b
Compare
492094b to
c844302
Compare
Hmm...are we sure plain text is a good idea? I would rather keep it base64 encoded unless we explicitly want our users tampering with the search parameters. You are correct, filtering, page sizes, etc. impact the cursor. Sometimes, you use the encoded string to track additional metadata such as what page you're on. If the search conditions are tampered with, then metadata like I have hesitations about plain text and would be more comfortable if we kept it encoded for now. |

TL;DR
Replaced offset-based pagination with cursor-based pagination for searching pipeline runs.
Old format (offset-based, base64-encoded)
The
page_tokenwas a base64-encoded JSON blob containingoffset,filter, andfilter_query:API request for page 2:
New format (cursor-based, plain text)
The
page_tokenis now a plain-textcreated_at~idcursor pointing to the last row of the previous page:API request for page 2:
What changed?
Functional
created_atandidfieldsOther
ix_pr_created_at_desc_id_descon(created_at DESC, id DESC)for efficient cursor queries(created_at, id) < (cursor_created_at, cursor_id)instead ofOFFSETpage_tokenparameter while changing internal implementationHow to test?
Why make this change?
Cursor-based pagination provides several advantages over offset-based pagination:
OFFSET(reads all rows that are skipped) operations on large datasets