Are the JPA setFirstResult() and setMaxResults() methods doing real pagination? I mean from the database point of view? or not?
For example, if a query returns 1000000 rows, and I am paging with those methods by pages of 1000, will the database be queried in the end for 1000 or 1000000 rows?
My point is: are those methods only there to limit the amount of entries retrieved to limit the memory footprint of the result of the query in the Java program or do they also serve as a way to be more conservative with the DBMS?
It's both JPA implementation and database specific, but generally speaking it's a dumb approach, such as using OFFSET/LIMIT or similar mechanism (based on Hibernate's implementation).
If the database can somehow make that efficient, then the corresponding JPA mechanism is efficient accordingly. If not (such as with Postgres), then you better roll your own paging mechanism.