> [!NOTE] Limit
> <table>
> <tr>
> <td width="25%"><img src="assets/ex_limit.png"></td>
> <td>A simple but effective optimization. The engine stops processing and returns the result set as soon as the requested number of rows has been emitted. This is most effective when combined with an <code>ORDER BY</code> and a supporting index. (Analogized by a proud raccoon wearing a tollkeeper cap, standing next to a bamboo slide, blowing a whistle and beckoning with his hand to stop the flow of packages once he has exactly five stacked up).</td>
> </tr>
> </table>
>
> ```sql
> -- Restricting the result set to 10 rows
> EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE)
> SELECT * FROM animals LIMIT 10;
> ```
>
> 
>
> ```text
> Limit (cost=0.00..0.17 rows=10 width=27) (actual time=0.003..0.004 rows=10 loops=1)
> Output: id, name, species_id, created_at
> Buffers: shared hit=2
> -> Seq Scan on public.animals (cost=0.00..174.00 rows=10000 width=27) (actual time=0.003..0.003 rows=10 loops=1)
> Output: id, name, species_id, created_at
> Buffers: shared hit=2
> Planning:
> Buffers: shared hit=73
> Planning Time: 0.162 ms
> Execution Time: 0.014 ms
> ```
>
> 
>
> <table>
> <tr>
> <td rowspan="2" width="25%"><img src="assets/ex_limit.svg"></td>
> <td><b>Performance</b></td><td>High performance; short-circuits the child node once the limit is reached.</td>
> </tr>
> <tr><td><b>Cost</b></td><td>A fractional cost based on the percentage of the input plan scanned.</td></tr>
> </table>