Skip to content

Commit

Permalink
chore: redo and clean all indexes on attributes instances tables (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobeal authored Aug 31, 2024
1 parent b23c237 commit 3faf0a4
Showing 1 changed file with 20 additions and 0 deletions.
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;

0 comments on commit 3faf0a4

Please sign in to comment.