Add an index on the firstName
column and you are ready to go (if you are gonna sort only/first by firstName). Of course this depends on your database. For MySQL see this page.
Increase performance of SELECT * FROM # ORDER BY # ASC LIMIT # OFFSET #;
-
07-10-2022 - |
Question
Basically, I want to do effective and fast lazy loading sorted list on a web page with HSQLDB. My current SQL query ineffective and slow:
SELECT o FROM Human AS o ORDER BY o.firstName ASC LIMIT 500k OFFSET 50;
Could I increase performance of it?
Domain Object:
@RooJpaActiveRecord
public class Human {
@NotNull
@Column(name="firstName")
String firstName;
@NotNull
@Column(name="lastName")
String lastName;
}
SQL table:
Id, firstName, lastName, Version
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow