Folder reorganize 1
This commit is contained in:
12
trends/live/composite indexes.txt
Normal file
12
trends/live/composite indexes.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Composite indexes for your use case
|
||||
CREATE INDEX idx_historicaldata_compound ON historicaldata (ID, TimeStamp DESC);
|
||||
CREATE INDEX idx_historicaldata_timestamp ON historicaldata (TimeStamp DESC);
|
||||
CREATE INDEX idx_id_names_lookup ON id_names (name, idnumber);
|
||||
|
||||
-- For date range queries
|
||||
CREATE INDEX idx_historicaldata_daterange ON historicaldata (TimeStamp, ID)
|
||||
WHERE TimeStamp >= '2020-01-01';
|
||||
|
||||
-- Partial indexes for recent data (if most queries are recent)
|
||||
CREATE INDEX idx_recent_data ON historicaldata (ID, TimeStamp DESC)
|
||||
WHERE TimeStamp >= NOW() - INTERVAL 30 DAY;
|
||||
Reference in New Issue
Block a user