You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation uses separate PostgreSQL tables for different time granularities (5m, 15m, 1h, etc.). TimescaleDB is a PostgreSQL extension to make SQL scalable for time-series data.
TimescaleDB is chosen over the TICK stack due to relative ease of code changes.
Instead of having separate tables for different time intervals, time-series data can be consolidated. For example:
Continuous materialized views automatically maintain pre-aggregated summaries of data. For example, pool_metrics can be grouped into 5-minute intervals with OHLCV data as follows:
CREATE MATERIALIZED VIEW pool_metrics_5m
WITH (timescaledb.continuous) ASSELECT
time_bucket('5 minutes', time) AS bucket, -- Group data into 5-min buckets
pool_id,
chain_id,
first(price, time) AS open, -- First price in interval
last(price, time) AS close, -- Last price in intervalmax(price) AS high, -- Highest price in intervalmin(price) AS low, -- Lowest price in intervalsum(volume) AS volume -- Total volume in intervalFROM pool_metrics
GROUP BY bucket, pool_id, chain_id;
Raw data can be kept for 30 days and summaries can be kept for a year:
The old existing tables would need to be migrated to the new ones. Application code such as models, CRUD operations, and cron jobs would need to be updated to reflect the new tables and materialized views. Monitoring may similarly need to be updated.
The text was updated successfully, but these errors were encountered:
This would be a rather large upgrade but yes, totally agree with the suggestion for timescale but to do the summary stats through materialized views would take a rather large change to backend.
The current implementation uses separate PostgreSQL tables for different time granularities (5m, 15m, 1h, etc.). TimescaleDB is a PostgreSQL extension to make SQL scalable for time-series data.
TimescaleDB is chosen over the TICK stack due to relative ease of code changes.
Instead of having separate tables for different time intervals, time-series data can be consolidated. For example:
Continuous materialized views automatically maintain pre-aggregated summaries of data. For example, pool_metrics can be grouped into 5-minute intervals with OHLCV data as follows:
Raw data can be kept for 30 days and summaries can be kept for a year:
The old existing tables would need to be migrated to the new ones. Application code such as models, CRUD operations, and cron jobs would need to be updated to reflect the new tables and materialized views. Monitoring may similarly need to be updated.
The text was updated successfully, but these errors were encountered: