Core limits /wp/v2 collections to per_page=100. Your own route has no limit until you write one.
Five habits from our plugins: ① Cap the page size: min( 100, max( 1, perpage ) ). ② No pager? nofoundrows skips the total count. ③ Reading meta per post? updatepostmetacache loads it in one batch instead of N+1 queries. Only titles? Turn it off. ④ Someone else’s API? Cache the answer: 4WP Weather keeps it in a transient for an hour. ⑤ Every loop needs an exit: our export stops after 20 pages of 200 rows.
Go deeper
- Full guide: 4wp.dev/development/rest-api/performance