When working with large datasets, fetching thousands of rows at once can slow down your application, increase server load, and consume unnecessary memory. To avoid this, use the LIMIT clause to restrict the number of rows returned by your query — especially useful when displaying preview data or paginated results on the front end.

1. General Syntax:-

SELECT column1, column2

FROM table_name

ORDER BY column_name

LIMIT number;

Example:-

SELECT name FROM users ORDER BY id LIMIT 10;

Output:- 

2. General Syntax for pagination:

SELECT column1, column2

FROM table_name

ORDER BY column_name

LIMIT number OFFSET offset_value;

Example:-

SELECT name FROM users ORDER BY id LIMIT 10 OFFSET 20;

Output:-

(This saves memory and improves load time for front-end applications. )