From dc46ed3c5dd9f2b48ca0e336b4ac882d45a89471 Mon Sep 17 00:00:00 2001
From: Cedric CAFFY <cedric.caffy@cern.ch>
Date: Wed, 22 Jan 2020 13:57:38 +0100
Subject: [PATCH] Added INDEX ARCHIVE_FILE_DFI_IDX on TABLE
 ARCHIVE_FILE(DISK_FILE_ID)

---
 catalogue/1.1/mysql_catalogue_schema.sql           | 1 +
 catalogue/1.1/oracle_catalogue_schema.sql          | 1 +
 catalogue/1.1/postgres_catalogue_schema.sql        | 1 +
 catalogue/1.1/sqlite_catalogue_schema.sql          | 1 +
 catalogue/AllCatalogueSchema.hpp                   | 4 ++++
 catalogue/common_catalogue_schema.sql              | 1 +
 catalogue/migrations/liquibase/oracle/1.0to1.1.sql | 8 +++++++-
 7 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/catalogue/1.1/mysql_catalogue_schema.sql b/catalogue/1.1/mysql_catalogue_schema.sql
index 1b308e9b6c..6e349a23a7 100644
--- a/catalogue/1.1/mysql_catalogue_schema.sql
+++ b/catalogue/1.1/mysql_catalogue_schema.sql
@@ -227,6 +227,7 @@ CREATE TABLE ARCHIVE_FILE(
   CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))
 );
 CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);
+CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);
 CREATE TABLE TAPE_FILE(
   VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,
   FSEQ                     BIGINT UNSIGNED     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,
diff --git a/catalogue/1.1/oracle_catalogue_schema.sql b/catalogue/1.1/oracle_catalogue_schema.sql
index 3cdc5b2823..d4fad39fe9 100644
--- a/catalogue/1.1/oracle_catalogue_schema.sql
+++ b/catalogue/1.1/oracle_catalogue_schema.sql
@@ -249,6 +249,7 @@ CREATE TABLE ARCHIVE_FILE(
   CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))
 );
 CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);
+CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);
 CREATE TABLE TAPE_FILE(
   VID                      VARCHAR2(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,
   FSEQ                     NUMERIC(20, 0)     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,
diff --git a/catalogue/1.1/postgres_catalogue_schema.sql b/catalogue/1.1/postgres_catalogue_schema.sql
index b27719df47..8afaa5ed84 100644
--- a/catalogue/1.1/postgres_catalogue_schema.sql
+++ b/catalogue/1.1/postgres_catalogue_schema.sql
@@ -234,6 +234,7 @@ CREATE TABLE ARCHIVE_FILE(
   CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))
 );
 CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);
+CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);
 CREATE TABLE TAPE_FILE(
   VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,
   FSEQ                     NUMERIC(20, 0)     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,
diff --git a/catalogue/1.1/sqlite_catalogue_schema.sql b/catalogue/1.1/sqlite_catalogue_schema.sql
index 8205204162..c6de928232 100644
--- a/catalogue/1.1/sqlite_catalogue_schema.sql
+++ b/catalogue/1.1/sqlite_catalogue_schema.sql
@@ -218,6 +218,7 @@ CREATE TABLE ARCHIVE_FILE(
   CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))
 );
 CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);
+CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);
 CREATE TABLE TAPE_FILE(
   VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,
   FSEQ                     INTEGER     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,
diff --git a/catalogue/AllCatalogueSchema.hpp b/catalogue/AllCatalogueSchema.hpp
index 51f560dd34..7a6da26ab1 100644
--- a/catalogue/AllCatalogueSchema.hpp
+++ b/catalogue/AllCatalogueSchema.hpp
@@ -1474,6 +1474,7 @@ namespace catalogue{
   "  CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))"
   ");"
   "CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);"
+  "CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);"
   "CREATE TABLE TAPE_FILE("
   "  VID                      VARCHAR2(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,"
   "  FSEQ                     NUMERIC(20, 0)     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,"
@@ -1774,6 +1775,7 @@ namespace catalogue{
   "  CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))"
   ");"
   "CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);"
+  "CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);"
   "CREATE TABLE TAPE_FILE("
   "  VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,"
   "  FSEQ                     BIGINT UNSIGNED     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,"
@@ -2064,6 +2066,7 @@ namespace catalogue{
   "  CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))"
   ");"
   "CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);"
+  "CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);"
   "CREATE TABLE TAPE_FILE("
   "  VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,"
   "  FSEQ                     INTEGER     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,"
@@ -2368,6 +2371,7 @@ namespace catalogue{
   "  CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))"
   ");"
   "CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);"
+  "CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);"
   "CREATE TABLE TAPE_FILE("
   "  VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,"
   "  FSEQ                     NUMERIC(20, 0)     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,"
diff --git a/catalogue/common_catalogue_schema.sql b/catalogue/common_catalogue_schema.sql
index e53299c994..838f4efdee 100644
--- a/catalogue/common_catalogue_schema.sql
+++ b/catalogue/common_catalogue_schema.sql
@@ -206,6 +206,7 @@ CREATE TABLE ARCHIVE_FILE(
   CONSTRAINT ARCHIVE_FILE_ID_BOOL_CK CHECK(IS_DELETED IN ('0', '1'))
 );
 CREATE INDEX ARCHIVE_FILE_DIN_DFP_IDX ON ARCHIVE_FILE(DISK_INSTANCE_NAME, DISK_FILE_PATH);
+CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);
 CREATE TABLE TAPE_FILE(
   VID                      VARCHAR(100)   CONSTRAINT TAPE_FILE_V_NN    NOT NULL,
   FSEQ                     UINT64TYPE     CONSTRAINT TAPE_FILE_F_NN    NOT NULL,
diff --git a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql
index a6bd689d71..bdddfdd9aa 100644
--- a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql
+++ b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql
@@ -83,10 +83,16 @@ ALTER TABLE LOGICAL_LIBRARY RENAME CONSTRAINT LOGICAL_LIBRARY_LLN TO LOGICAL_LIB
 --changeset ccaffy:12 failOnError:true dbms:oracle
 --preconditions onFail:HALT onError:HALT
 --precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
+CREATE INDEX ARCHIVE_FILE_DFI_IDX ON ARCHIVE_FILE(DISK_FILE_ID);
+--rollback DROP INDEX ARCHIVE_FILE_DFI_IDX;
+
+--changeset ccaffy:13 failOnError:true dbms:oracle
+--preconditions onFail:HALT onError:HALT
+--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
 UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=1;
 --rollback UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=0
 
---changeset ccaffy:13 failOnError:true dbms:oracle
+--changeset ccaffy:14 failOnError:true dbms:oracle
 --preconditions onFail:HALT onError:HALT
 --precondition-sql-check expectedResult:"1.1" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
 UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MAJOR=NULL;
-- 
GitLab