Interview Question

What is OFFSET?

OFFSET skips rows, but predictable paging also needs ORDER BY.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

OFFSET skips a specified number of result rows before returning rows. • A stable ORDER BY is needed for predictable pagination. • Large offsets can still require the database to process skipped rows. • Keyset pagination may perform better for deep pages.

💡 SQL Example

SELECT employee_id, name FROM employees ORDER BY employee_id OFFSET 20 ROWS FETCH FIRST 10 ROWS ONLY;

Result

Rows 21 through 30

⚡ Quick Revision

OFFSET skips rows, but predictable paging also needs ORDER BY.