Issue #2060: Consolidate grid indexes.
Change-Id: Ibc77133cd1b016ef85bae61e47e373a30e6e4d23 Former-commit-id: 892c0f28a13d53118141efe14762deebe169d7ba
This commit is contained in:
parent
5648e27bbc
commit
6143d43329
4 changed files with 70 additions and 42 deletions
|
@ -16,6 +16,21 @@ function dropDatauri {
|
|||
}
|
||||
|
||||
|
||||
# takes one arg: name of the index
|
||||
function dropIndex {
|
||||
${PSQL} -U awips -d metadata -c "DROP INDEX IF EXISTS \"$1\";"
|
||||
}
|
||||
|
||||
# takes three args: table, index name, columns
|
||||
# will first drop the index if it exists and then adds it back, this is
|
||||
# fairly inefficient if it does exist but operationally it won't exist and for
|
||||
# testing this allows the script to be run easily as a noop.
|
||||
function dropAndAddIndex {
|
||||
${PSQL} -U awips -d metadata -c "DROP INDEX IF EXISTS \"$2\";"
|
||||
${PSQL} -U awips -d metadata -c "CREATE INDEX $2 ON $1 USING btree $3;"
|
||||
}
|
||||
|
||||
|
||||
# takes three args: table, constraint name, unique columns
|
||||
# will first drop the constraint if it exists and then adds it back, this is
|
||||
# fairly inefficient if it does exist but operationally it won't exist and for
|
||||
|
@ -28,14 +43,24 @@ function dropAndAddConstraint {
|
|||
echo "FATAL: The update has failed."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# takes one arg: name of the table
|
||||
function vacuumTable {
|
||||
${PSQL} -U awips -d metadata -c "VACUUM FULL ANALYZE $1"
|
||||
}
|
||||
|
||||
echo "INFO: Dropping dataURI columns."
|
||||
|
||||
dropAndAddConstraint grid grid_reftime_forecasttime_rangestart_rangeend_info_id "(refTime, forecastTime, rangestart, rangeend, info_id)"
|
||||
dropAndAddConstraint grid_info grid_info_datasetid_secondaryid_ensembleid_location_id_parameter_abbreviation_level_id "(datasetid, secondaryid, ensembleid, location_id, parameter_abbreviation, level_id)"
|
||||
dropAndAddConstraint grid grid_reftime_forecasttime_info_id_rangestart_rangeend_key "(refTime, forecastTime, info_id, rangestart, rangeend)"
|
||||
dropAndAddConstraint grid_info grid_info_datasetid_parameter_abbreviation_level_id_seconda_key "(datasetid, parameter_abbreviation, level_id, secondaryid, ensembleid, location_id)"
|
||||
dropIndex gridDatasetReftime_idx
|
||||
dropIndex grid_reftimeindex
|
||||
dropIndex gridinfoNameParamLevel_idx
|
||||
dropAndAddIndex grid grid_info_id_index "(info_id)"
|
||||
dropDatauri
|
||||
vacuumTable grid
|
||||
vacuumTable grid_info
|
||||
|
||||
|
||||
echo "INFO: grid dataURI column dropped successfully"
|
||||
|
|
|
@ -17,17 +17,6 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
CREATE INDEX "gridDatasetReftime_idx"
|
||||
ON grid
|
||||
USING btree
|
||||
(info_id, reftime, forecasttime);
|
||||
|
||||
CREATE INDEX "gridinfoNameParamLevel_idx"
|
||||
ON grid_info
|
||||
USING btree
|
||||
(datasetid, parameter_abbreviation, level_id);
|
||||
|
||||
CREATE INDEX "gridinfoSecondryId_idx"
|
||||
ON grid_info
|
||||
USING btree
|
||||
|
|
|
@ -63,8 +63,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name = "grid_info", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"datasetid", "secondaryid", "ensembleid", "location_id",
|
||||
"parameter_abbreviation", "level_id" }) })
|
||||
"datasetid", "parameter_abbreviation", "level_id", "secondaryid",
|
||||
"ensembleid", "location_id" }) })
|
||||
@SequenceGenerator(name = "GRIDINFO_GENERATOR", sequenceName = "gridinfo_seq", allocationSize = 1)
|
||||
@DynamicSerialize
|
||||
public class GridInfoRecord extends PersistableDataObject<Integer> {
|
||||
|
@ -196,59 +196,74 @@ public class GridInfoRecord extends PersistableDataObject<Integer> {
|
|||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
result = (prime * result)
|
||||
+ ((datasetId == null) ? 0 : datasetId.hashCode());
|
||||
result = prime * result
|
||||
result = (prime * result)
|
||||
+ ((ensembleId == null) ? 0 : ensembleId.hashCode());
|
||||
result = prime * result + ((level == null) ? 0 : level.hashCode());
|
||||
result = prime * result
|
||||
result = (prime * result) + ((level == null) ? 0 : level.hashCode());
|
||||
result = (prime * result)
|
||||
+ ((location == null) ? 0 : location.hashCode());
|
||||
result = prime * result
|
||||
result = (prime * result)
|
||||
+ ((parameter == null) ? 0 : parameter.hashCode());
|
||||
result = prime * result
|
||||
result = (prime * result)
|
||||
+ ((secondaryId == null) ? 0 : secondaryId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
GridInfoRecord other = (GridInfoRecord) obj;
|
||||
if (datasetId == null) {
|
||||
if (other.datasetId != null)
|
||||
if (other.datasetId != null) {
|
||||
return false;
|
||||
} else if (!datasetId.equals(other.datasetId))
|
||||
}
|
||||
} else if (!datasetId.equals(other.datasetId)) {
|
||||
return false;
|
||||
}
|
||||
if (ensembleId == null) {
|
||||
if (other.ensembleId != null)
|
||||
if (other.ensembleId != null) {
|
||||
return false;
|
||||
} else if (!ensembleId.equals(other.ensembleId))
|
||||
}
|
||||
} else if (!ensembleId.equals(other.ensembleId)) {
|
||||
return false;
|
||||
}
|
||||
if (level == null) {
|
||||
if (other.level != null)
|
||||
if (other.level != null) {
|
||||
return false;
|
||||
} else if (!level.equals(other.level))
|
||||
}
|
||||
} else if (!level.equals(other.level)) {
|
||||
return false;
|
||||
}
|
||||
if (location == null) {
|
||||
if (other.location != null)
|
||||
if (other.location != null) {
|
||||
return false;
|
||||
} else if (!location.equals(other.location))
|
||||
}
|
||||
} else if (!location.equals(other.location)) {
|
||||
return false;
|
||||
}
|
||||
if (parameter == null) {
|
||||
if (other.parameter != null)
|
||||
if (other.parameter != null) {
|
||||
return false;
|
||||
} else if (!parameter.equals(other.parameter))
|
||||
}
|
||||
} else if (!parameter.equals(other.parameter)) {
|
||||
return false;
|
||||
}
|
||||
if (secondaryId == null) {
|
||||
if (other.secondaryId != null)
|
||||
if (other.secondaryId != null) {
|
||||
return false;
|
||||
} else if (!secondaryId.equals(other.secondaryId))
|
||||
}
|
||||
} else if (!secondaryId.equals(other.secondaryId)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,14 +76,13 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "gridseq")
|
||||
@Table(name = "grid", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"refTime", "forecastTime", "rangestart", "rangeend", "info_id" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
* No need for a separate refTime/forecastTime index since its included in grid
|
||||
* unique constraint
|
||||
*/
|
||||
@org.hibernate.annotations.Table(appliesTo = "grid", indexes = { @Index(name = "grid_refTimeIndex", columnNames = {
|
||||
"refTime", "forecastTime" }) })
|
||||
@Table(name = "grid", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"refTime", "forecastTime", "info_id", "rangestart", "rangeend" }) })
|
||||
@org.hibernate.annotations.Table(appliesTo = "grid", indexes = { @Index(name = "grid_info_id_index", columnNames = { "info_id" }) })
|
||||
@DynamicSerialize
|
||||
public class GridRecord extends PersistablePluginDataObject implements
|
||||
ISpatialEnabled {
|
||||
|
|
Loading…
Add table
Reference in a new issue