From 1a4ec662a583eb5201e3b06d444e4de0ae2028f9 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 21 Aug 2021 15:44:22 +0100 Subject: [PATCH] Add a height index to the ATStates table. DO NOT MERGE. This is a throwaway branch which can be attempted by those with a high spec CPU, to get an idea on how long this process takes. Only then can we consider adding it as its own case, but I suspect we will need to wait until we have solved the database size issues first. --- .../hsqldb/HSQLDBDatabaseUpdates.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseUpdates.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseUpdates.java index 2e399be1..9ecfbed1 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseUpdates.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseUpdates.java @@ -863,7 +863,26 @@ public class HSQLDBDatabaseUpdates { } default: - // nothing to do + + // Check if we already have an ATStatesHeight index + ResultSet indexResultSet = stmt.executeQuery("SELECT INDEX_NAME FROM INFORMATION_SCHEMA.SYSTEM_INDEXINFO where INDEX_NAME='ATSTATESHEIGHTINDEX'"); + final boolean hasHeightIndex = indexResultSet.next(); + if (!hasHeightIndex) { + // We need to add the missing height index (as some nodes originally reshaped without it in case 34) + + LOGGER.info("Rebuilding AT states height index in repository - this will take a very long time..."); + LOGGER.info("No progress indicator is available, so please check back every few hours."); + stmt.execute("CREATE INDEX ATStatesHeightIndex ON ATStates (height)"); + stmt.execute("CHECKPOINT"); + + } + + // Make sure to return false, as we don't want to increase the database version. + // This is a throwaway build to add the index on nodes with enough CPU to do so. + // We may ulimately include this addition in a release build, as its own official case, + // but it takes too long right now for us to justify including this in a mainline release. + // Once we have "top-only-sync" and have been able to get the archived data out of the + // db, this will become more achievable for the regular user. return false; } }