Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The method of utilizing Limit in a query to search only the index column and avoid scanning all the rows involves adding a LIMIT clause to the query. The LIMIT clause restricts the number of rows returned by the query, and can also optimize the search by limiting the scan to the indexed column only.

For example, consider a table with columns id (indexed) and name:

SELECT id FROM table_name WHERE id > 100 LIMIT 10;

In this query, the LIMIT clause restricts the result set to 10 rows, and the WHERE clause restricts the search to the indexed id column. This helps avoid scanning all the rows in the table, and instead only looks at the index to retrieve the matching rows.