-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: redo and clean all indexes on attributes instances tables (#1222)
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
search-service/src/main/resources/db/migration/V0_42__fix_indexes_in_hypertables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Default indexes created by Timescale that should not have been removed | ||
-- https://docs.timescale.com/use-timescale/latest/hypertables/about-hypertables/#hypertable-indexes | ||
CREATE INDEX IF NOT EXISTS attribute_instance_time_idx | ||
ON attribute_instance(time DESC ); | ||
CREATE INDEX IF NOT EXISTS attribute_instance_audit_time_idx | ||
ON attribute_instance_audit(time DESC); | ||
|
||
-- Indexes on main keys used when doing a temporal query | ||
-- As recommended in https://docs.timescale.com/getting-started/latest/create-hypertable/#creating-your-first-hypertable | ||
CREATE INDEX attribute_instance_tea_idx | ||
ON attribute_instance(temporal_entity_attribute, time DESC); | ||
CREATE INDEX attribute_instance_audit_tea_timeproperty_idx | ||
ON attribute_instance_audit(temporal_entity_attribute, time_property, time DESC); | ||
|
||
-- Remove current unwanted indexes | ||
DROP INDEX IF EXISTS attribute_instance_audit_tea_time_property_idx; | ||
DROP INDEX IF EXISTS attribute_instance_temporal_entity_attribute_idx; | ||
|
||
-- Same as attribute_instance_time_idx created above, but with a deprecated reference to observed_at column | ||
DROP INDEX IF EXISTS attribute_instance_observed_at_idx; |