JoaoJandre commented on code in PR #11443:
URL: https://github.com/apache/cloudstack/pull/11443#discussion_r4404651568
##########
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42300to2400.java:
##########
@@ -27,4 +29,25 @@ public String[] getUpgradableVersionRange() {
public String getUpgradedVersion() {
return "24.0.0";
}
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ addIndexes(conn);
+ dropOldIndexes(conn);
+ }
+
+ private void addIndexes(Connection conn) {
+ DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__archived__created__id",
+ "archived", "created", "id");
+ DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__account_id__archived__created__id",
+ "account_id", "archived", "created", "id");
+ DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__domain_id__archived__created__id",
+ "domain_id", "archived", "created", "id");
+ DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__resource_type__resource_id__archived__created__id",
+ "resource_type", "resource_id", "archived", "created", "id");
Review Comment:
When using innoDB, the primary key is already added to the end of every
index:
"In InnoDB tables, the primary key is included as a suffix in all other
indexes. Therefore, keeping the primary key compact (e.g., using an appropriate
integer type) is important for performance and storage efficiency."
source:
https://mariadb.com/docs/server/mariadb-quickstart-guides/mariadb-indexes-guide
```suggestion
"archived", "created", "id");
DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__account_id__archived__created",
"account_id", "archived", "created");
DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__domain_id__archived__created",
"domain_id", "archived", "created");
DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event",
"i_event__resource_type__resource_id__archived__created",
"resource_type", "resource_id", "archived", "created");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]