0
0
HLDsystem_design~10 mins

Pagination patterns (cursor, offset) in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the correct pagination method for simple page numbers.

HLD
SELECT * FROM items ORDER BY id LIMIT 10 OFFSET [1];
Drag options to blanks, or click blank then click option'
Apage_size
Bcursor_value
Cpage_number * 10
Dtotal_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using cursor_value instead of offset for offset pagination.
2fill in blank
medium

Complete the code to fetch the next page using cursor pagination.

HLD
SELECT * FROM items WHERE id > [1] ORDER BY id LIMIT 10;
Drag options to blanks, or click blank then click option'
Apage_number
Boffset_value
Ctotal_items
Dlast_seen_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using page_number or offset_value in cursor pagination query.
3fill in blank
hard

Fix the error in the pagination query to avoid skipping or duplicating items.

HLD
SELECT * FROM items WHERE id >= [1] ORDER BY id LIMIT 10;
Drag options to blanks, or click blank then click option'
Alast_seen_id
Bpage_number
Coffset_value
Dtotal_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' instead of '>' causing duplicate items on pages.
4fill in blank
hard

Fill both blanks to implement offset pagination with page size and offset calculation.

HLD
SELECT * FROM items ORDER BY created_at DESC LIMIT [1] OFFSET [2];
Drag options to blanks, or click blank then click option'
Apage_size
Bpage_number
Cpage_number * page_size
Dcursor_value
Attempts:
3 left
💡 Hint
Common Mistakes
Using cursor_value in offset pagination query.
5fill in blank
hard

Fill all three blanks to implement cursor pagination with sorting and cursor parameter.

HLD
SELECT * FROM items WHERE [1] > [2] ORDER BY [3] ASC LIMIT 20;
Drag options to blanks, or click blank then click option'
Acreated_at
Bcursor_timestamp
Cid
Dpage_number
Attempts:
3 left
💡 Hint
Common Mistakes
Using page_number in cursor pagination query.