Improve HSQLDB query for finding latest AT state data

This commit is contained in:
catbref 2020-08-12 14:18:05 +01:00
parent d4ac87f91d
commit ab1de1aafa

View File

@ -268,7 +268,8 @@ public class HSQLDBATRepository implements ATRepository {
+ "FROM ATStates "
+ "WHERE AT_address = ? "
+ "ORDER BY height DESC "
+ "LIMIT 1";
+ "LIMIT 1 "
+ "USING INDEX";
try (ResultSet resultSet = this.repository.checkedExecute(sql, atAddress)) {
if (resultSet == null)
@ -299,7 +300,8 @@ public class HSQLDBATRepository implements ATRepository {
+ "FROM ATStates "
+ "WHERE ATStates.AT_address = ATs.AT_address "
+ "ORDER BY height DESC "
+ "LIMIT 1"
+ "LIMIT 1 "
+ "USING INDEX"
+ ") AS FinalATStates "
+ "WHERE code_hash = ? ");