Query limits issue

Please does the query of a database search all the items in the database even though it has 100,000 entries(search all items based on filter criteria) with a limit set at .limit(1000) and return a maximum of 1000 results?
or
Does the query of a database search the first 1000 rows of the database even though the database has 100,000 entries with a limit set at .limit(1000) and return a maximum of 1000 results?
also
Does setFilter and .getTotalCount() of a dataset have any limits?

Example:
If you have a 5000-items sized DB, then you will need to run 5x-queries with a Limit of 1000 and every NEW loop you will have to skip loopings x 1000.
This way you are able to query big sized DBs.
Also search for → .promisseAll()

If activities of users on the site creates queries to retrieve a single entry and some users have upto 4000 entries while others have 70 entries, how do I write a general code that will skip the first 3000 entries without isolating those with 70 entries just to return one entry with index 3888?