From 1bd72c18ed36193791c7213c2d21180abd7c03e9 Mon Sep 17 00:00:00 2001 From: Marta Kuczora Date: Thu, 19 Mar 2026 14:36:40 +0100 Subject: [PATCH] HIVE-29418: Add Index to MIN_HISTORY_WRITE_ID table --- .../src/main/sql/derby/hive-schema-4.3.0.derby.sql | 2 ++ .../src/main/sql/derby/upgrade-4.2.0-to-4.3.0.derby.sql | 2 ++ .../src/main/sql/mssql/hive-schema-4.3.0.mssql.sql | 2 ++ .../src/main/sql/mssql/upgrade-4.2.0-to-4.3.0.mssql.sql | 2 ++ .../src/main/sql/mysql/hive-schema-4.3.0.mysql.sql | 2 ++ .../src/main/sql/mysql/upgrade-4.2.0-to-4.3.0.mysql.sql | 2 ++ .../src/main/sql/oracle/hive-schema-4.3.0.oracle.sql | 2 ++ .../src/main/sql/oracle/upgrade-4.2.0-to-4.3.0.oracle.sql | 2 ++ .../src/main/sql/postgres/hive-schema-4.3.0.postgres.sql | 2 ++ .../src/main/sql/postgres/upgrade-4.2.0-to-4.3.0.postgres.sql | 2 ++ 10 files changed, 20 insertions(+) diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.3.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.3.0.derby.sql index d8ab7f2e134c..39d17cc88be7 100644 --- a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.3.0.derby.sql +++ b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.3.0.derby.sql @@ -708,6 +708,8 @@ CREATE TABLE MIN_HISTORY_WRITE_ID ( MH_WRITEID bigint NOT NULL ); +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + CREATE TABLE MIN_HISTORY_LEVEL ( MHL_TXNID bigint NOT NULL, MHL_MIN_OPEN_TXNID bigint NOT NULL, diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-4.2.0-to-4.3.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-4.2.0-to-4.3.0.derby.sql index 331c26b11f0f..4aa072134523 100644 --- a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-4.2.0-to-4.3.0.derby.sql +++ b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-4.2.0-to-4.3.0.derby.sql @@ -1,5 +1,7 @@ ALTER TABLE HIVE_LOCKS ADD COLUMN HL_CATALOG varchar(128) NOT NULL DEFAULT 'hive'; ALTER TABLE MATERIALIZATION_REBUILD_LOCKS ADD COLUMN MRL_CAT_NAME varchar(128) NOT NULL DEFAULT 'hive'; +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + -- This needs to be the last thing done. Insert any changes above this line. UPDATE "APP".VERSION SET SCHEMA_VERSION='4.3.0', VERSION_COMMENT='Hive release version 4.3.0' where VER_ID=1; diff --git a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.3.0.mssql.sql b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.3.0.mssql.sql index 9db45f4a5ef9..ad2a45fc02b9 100644 --- a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.3.0.mssql.sql +++ b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.3.0.mssql.sql @@ -1207,6 +1207,8 @@ CREATE TABLE MIN_HISTORY_WRITE_ID ( MH_WRITEID bigint NOT NULL ); +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + CREATE TABLE MIN_HISTORY_LEVEL ( MHL_TXNID bigint NOT NULL, MHL_MIN_OPEN_TXNID bigint NOT NULL, diff --git a/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-4.2.0-to-4.3.0.mssql.sql b/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-4.2.0-to-4.3.0.mssql.sql index a53333d07bc6..58a884a52c78 100644 --- a/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-4.2.0-to-4.3.0.mssql.sql +++ b/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-4.2.0-to-4.3.0.mssql.sql @@ -3,6 +3,8 @@ SELECT 'Upgrading MetaStore schema from 4.2.0 to 4.3.0' AS MESSAGE; ALTER TABLE HIVE_LOCKS ADD HL_CATALOG nvarchar(128) NOT NULL DEFAULT 'hive'; ALTER TABLE MATERIALIZATION_REBUILD_LOCKS ADD MRL_CAT_NAME nvarchar(128) NOT NULL DEFAULT 'hive'; +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='4.3.0', VERSION_COMMENT='Hive release version 4.3.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 4.2.0 to 4.3.0' AS MESSAGE; diff --git a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.3.0.mysql.sql b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.3.0.mysql.sql index c362aa89cefd..03e37811f6cf 100644 --- a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.3.0.mysql.sql +++ b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.3.0.mysql.sql @@ -1138,6 +1138,8 @@ CREATE TABLE MIN_HISTORY_WRITE_ID ( FOREIGN KEY (MH_TXNID) REFERENCES TXNS (TXN_ID) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + CREATE TABLE MIN_HISTORY_LEVEL ( MHL_TXNID bigint NOT NULL, MHL_MIN_OPEN_TXNID bigint NOT NULL, diff --git a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-4.2.0-to-4.3.0.mysql.sql b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-4.2.0-to-4.3.0.mysql.sql index 4c186c2f7501..5149dce33cff 100644 --- a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-4.2.0-to-4.3.0.mysql.sql +++ b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-4.2.0-to-4.3.0.mysql.sql @@ -3,6 +3,8 @@ SELECT 'Upgrading MetaStore schema from 4.2.0 to 4.3.0' AS MESSAGE; ALTER TABLE HIVE_LOCKS ADD HL_CATALOG varchar(128) NOT NULL DEFAULT 'hive'; ALTER TABLE MATERIALIZATION_REBUILD_LOCKS ADD MRL_CAT_NAME varchar(128) NOT NULL DEFAULT 'hive'; +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='4.3.0', VERSION_COMMENT='Hive release version 4.3.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 4.2.0 to 4.3.0' AS MESSAGE; diff --git a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.3.0.oracle.sql b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.3.0.oracle.sql index 500b794ceb5d..33958a17852f 100644 --- a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.3.0.oracle.sql +++ b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.3.0.oracle.sql @@ -1126,6 +1126,8 @@ CREATE TABLE MIN_HISTORY_WRITE_ID ( MH_WRITEID NUMBER(19) NOT NULL ); +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + CREATE TABLE MIN_HISTORY_LEVEL ( MHL_TXNID NUMBER(19) NOT NULL, MHL_MIN_OPEN_TXNID NUMBER(19) NOT NULL, diff --git a/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-4.2.0-to-4.3.0.oracle.sql b/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-4.2.0-to-4.3.0.oracle.sql index eb5b7440b6d4..bb210a6623c5 100644 --- a/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-4.2.0-to-4.3.0.oracle.sql +++ b/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-4.2.0-to-4.3.0.oracle.sql @@ -3,6 +3,8 @@ SELECT 'Upgrading MetaStore schema from 4.2.0 to 4.3.0' AS Status from dual; ALTER TABLE HIVE_LOCKS ADD (HL_CATALOG VARCHAR2(128) DEFAULT 'hive' NOT NULL); ALTER TABLE MATERIALIZATION_REBUILD_LOCKS ADD (MRL_CAT_NAME VARCHAR2(128) DEFAULT 'hive' NOT NULL); +CREATE INDEX MIN_HISTORY_WRITE_ID_IDX ON MIN_HISTORY_WRITE_ID (MH_DATABASE, MH_TABLE, MH_WRITEID); + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='4.3.0', VERSION_COMMENT='Hive release version 4.3.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 4.2.0 to 4.3.0' AS Status from dual; diff --git a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.3.0.postgres.sql b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.3.0.postgres.sql index dcb389c9c740..10eb38923261 100644 --- a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.3.0.postgres.sql +++ b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.3.0.postgres.sql @@ -1761,6 +1761,8 @@ CREATE TABLE "MIN_HISTORY_WRITE_ID" ( "MH_WRITEID" bigint NOT NULL ); +CREATE INDEX "MIN_HISTORY_WRITE_ID_IDX" ON "MIN_HISTORY_WRITE_ID" ("MH_DATABASE", "MH_TABLE", "MH_WRITEID"); + CREATE TABLE "MIN_HISTORY_LEVEL" ( "MHL_TXNID" bigint NOT NULL, "MHL_MIN_OPEN_TXNID" bigint NOT NULL, diff --git a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-4.2.0-to-4.3.0.postgres.sql b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-4.2.0-to-4.3.0.postgres.sql index a572b4100e7f..bdd28ce20298 100644 --- a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-4.2.0-to-4.3.0.postgres.sql +++ b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-4.2.0-to-4.3.0.postgres.sql @@ -3,6 +3,8 @@ SELECT 'Upgrading MetaStore schema from 4.2.0 to 4.3.0'; ALTER TABLE "HIVE_LOCKS" ADD COLUMN "HL_CATALOG" varchar(128) NOT NULL DEFAULT 'hive'; ALTER TABLE "MATERIALIZATION_REBUILD_LOCKS" ADD COLUMN "MRL_CAT_NAME" varchar(128) NOT NULL DEFAULT 'hive'; +CREATE INDEX "MIN_HISTORY_WRITE_ID_IDX" ON "MIN_HISTORY_WRITE_ID" ("MH_DATABASE", "MH_TABLE", "MH_WRITEID"); + -- These lines need to be last. Insert any changes above. UPDATE "VERSION" SET "SCHEMA_VERSION"='4.3.0', "VERSION_COMMENT"='Hive release version 4.3.0' where "VER_ID"=1; SELECT 'Finished upgrading MetaStore schema from 4.2.0 to 4.3.0';