From df4925e3a496cba918aec025f6f5d730b9e857e7 Mon Sep 17 00:00:00 2001 From: Avraham Sakal Date: Fri, 5 Jul 2024 16:47:15 -0400 Subject: [PATCH] add materialized view to keep individual contract existences --- server/tables.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/tables.sql b/server/tables.sql index c9fc63f..7d641cd 100644 --- a/server/tables.sql +++ b/server/tables.sql @@ -23,6 +23,21 @@ CREATE TABLE option_contract_existences ENGINE ReplacingMergeTree() PRIMARY KEY (asOfDate, symbol) ORDER BY (asOfDate, symbol, expirationDate, strike, type); +CREATE MATERIALIZED VIEW option_contract_existences_mv TO option_contract_existences +AS +SELECT + toDate(tsStart) as asOfDate, + symbol, + expirationDate, + strike, + type +FROM option_contract_aggregates +GROUP BY + asOfDate, + symbol, + expirationDate, + strike, + type; CREATE TABLE option_contracts (