AHA : Scalable Alternative History Analysis for Operational Timeseries Applications Conference: Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining V.1; August 9–13, 2026; Jeju Island, Republic of Korea. Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining V.1 (KDD 2026), August 9–13, 2026, Jeju Island, Republic of Korea ISBN: 979-8-4007-2258-5/2026/08 DOI: 10.1145/3770854.3783945 CCS: Information systems Database management system engines CCS: Computing methodologies Supervised learning CCS: Computing methodologies Machine learning algorithms Harshavardhan Kamarthi, Harshil Shah, Henry Milner, Sayan Sinha, Yan Li, B. Aditya Prakash, Vyas Sekar Abstract . Many operational systems collect high-dimensional timeseries data about users/systems on key performance metrics. For instance, ISPs, content distribution networks, and video delivery services collect quality of experience metrics for user sessions associated with metadata (e.g., location, device, ISP). Over such historical data, operators and data analysts often need to run retrospective analysis; e.g., analyze anomaly detection algorithms, experiment with different configurations for alerts, evaluate new algorithms, and so on. We refer to this class of workloads as alternative history analysis for operational datasets. We show that in such settings, traditional data processing solutions (e.g., data warehouses, sampling, sketching, big-data systems) either pose high operational costs or do not guarantee accurate replay. We design and implement a system called AHA (Alternative History Analytics), that overcomes both challenges to provide cost efficiency and fidelity for high-dimensional data. The design of AHA is based on analytical and empirical insights about such workloads: 1) the decomposability of underlying statistics; 2) sparsity in terms of active number of subpopulations over attribute-value combinations; and 3) efficiency structure of aggregation operations in modern analytics databases. Using multiple real-world datasets and as well as case-studies on production pipelines at a large video analytics company, we show that AHA provides 100% accuracy for a broad range of downstream tasks and up to 85 × \times lower total cost of ownership (i.e., compute + storage) compared to conventional methods. † † cc-license: by 1. Introduction Many operational systems collect high-dimensional data about user and system-level performance indices over time. Analysts need to run diverse algorithms on this collected data; e.g. anomaly detection over subgroups of users grouped by their attributes. For instance, a large video monitoring system collects ‘quality of experience’ metrics (e.g., bitrate, buffering) for video sessions to find anomalous patterns affecting subgroups of users ( 22 ; 27 ) . These patterns might include performance degradation affecting subgroup; e.g., are users from a ISP-city combination showing degraded performance? Operational analytics tasks often require the ability to perform alternative history analytics over longitudinal datasets ( 28 ) . For instance, ML scientists may need to do regression testing (i.e., CI/CD) on historical datasets for benchmarking ( 24 ) . For anomaly detection, a customer may query if alerts triggered several weeks ago would be suppressed by using different sensitivity thresholds ( 32 ) . Supporting alternative history analysis in operational settings is challenging. The datasets and analytics entail significant scale, cost, unpredictability of downstream tasks, and combinatorially large subgroups of interest. Indeed, several seemingly natural solutions fall short. As such, achieving low total cost of ownership and accurate replay for unforeseen tasks has been elusive. To see why, consider the strawman solutions from Table 1 . On one extreme, we can store the raw session measurements (i.e., attributes, metrics) per time step in a database and compute the combinations/statistics of interest when the query is issued. Unfortunately, there are data retention and cost challenges; e.g., there may be terabytes of raw user session data per day. At the other extreme, we can precompute a few attribute combinations (e.g., “heavy hitters) and statistics of interest. Similarly, another natural approach will be to only store the data about the alerts triggered. However, these approaches lack coverage over future queries that users want to try. Solution Low Cost for High Dimensional Data High fidelity/flexibility Support for wide range of stats. Store raw session data No Yes Yes Sample across sessions Yes No No Subpopulation statistics using sketches (e.g. ( 27 ) ) Yes No No Key-value store for all subgroup statistics (e.g., ( 4 ) ) No Yes Yes Alternative history Analysis ( AHA ) Yes Yes Yes Table 1 . Conventional solutions fall short of our key requirements for supporting alternative history analysis for operational time series tasks. Figure 1 . Relative costs of baselines w.r.t AHA to reach given minimum accuracy for at least 90 percentile of cohorts. AHA is 5.6x better than the best 100% accurate baseline, 73x cheaper than the default baseline of storing the raw data, and can be over 100x cheaper than approximate solutions to attain a common goal of >95\% accuracy. In this paper, we present the design and implementation of AHA , a practical system for supporting alternative history analysis in operational systems. The design of AHA is based on key analytical and empirical insights on the structure of operational data, query patterns, the downstream tasks that are typically used in these settings, and the capabilities of modern data processing systems. We create a practical system, where at data ingest time we track necessary statistics of the metrics for multiple (or all possible) subsets of subpopulations, from which metrics for other groups can be derived. Then, when the future alternative analytics history task is issued, we can compute the desired metrics of interest. This decoupled workflow enables us to delay the binding between the compute-at-ingest and the compute-at-query time to enable low total cost of ownership and accurate replay for unforeseen tasks . In summary, our work makes the following contributions: (1) Formulating alternative history analysis (§ 2 ): To the best of our knowledge, we are the first to formulate the alternative history analysis in operational time series settings. We identify the key cost and accuracy challenges in supporting this capability at scale; (2) Design and implementation of AHA (§ 4 ): We design and implement AHA , which enables retrieval of wide range of features for any possible group efficiently; (3) Correctness and coverage guarantees (§ 4 ): We provide theoretical guarantees establishing perfect accuracy of AHA under a broad spectrum of downstream tasks and methods; and (4) Benchmarking on real-world deployment scenarios (§ 5 ): We benchmark AHA and other state-of-art solutions on multiple datasets, including using it in production at a large video analytics company. We show that AHA provides 34-85 times less total ownership cost without loss in accuracy compared to baselines, which enables cost savings of over $0.7M per month. We also provide a deployment-study observing the impact on a production data pipeline with 6.2 times reduced total cost. 2. Background and Motivation In this section, we provide background on the structure of timeseries analytics tasks in operational settings and the need for alternative history analytics. We identify requirements to support these use cases and discuss why existing solutions fall short. 2.1. Operational Timeseries Analytics We consider time-series analytics workflows that appear in operational settings . At a high level, operational settings deal with high dimensional data and operators are interested in spatiotemporal insights across multiple user/endpoint subgroups to drive operations. To make this concrete, we consider the real-world example of large video analytics service on which this system is deployed. Video analytics services perform Quality of Experience (QoE) analysis on user data, enabling content and internet providers to improve user experience, viewership retention, and satisfaction ( 22 ) . Various video analytics metrics are collected from video sessions consisting of many different users with different characteristics. These metrics include bitrate, number of frames dropped, etc. Each user’s viewing session is also annotated with additional metadata called attributes . Typical analysis workflows involve identifying important patterns in metrics over groups of users categorized by their similarities in a subset of their attributes (such as geolocation, ISP, device used, etc.). For example, when buffering times of users from a state using a specific ISP are unusually high, the ISP can be notified to rectify any network issues. Detecting QoE issues and patterns entails detecting anomalies in generated metrics for each user group determined by the common set of attribute assignments among the users in the group. Typical datasets contain millions of possible user groups based on the number and possible combinations of user attributes. These groups are monitored for patterns in multiple metrics. Similar user and product analytics applications are encountered in other domains such as network analysis, monitoring logs, usage analytics etc. where data from multiple types of users are collected and analyzed in other domains; e.g., telecommunications, observability, IoT, mobile/ad analytics, and so on ( 16 ; 6 ; 15 ; 10 ; 20 ; 30 ) . 2.1.1. Datasets schema and typical query templates We define the data schema for subpopulation analytics using video analytics since it is our primary application (See Fig. 2 ). The dataset consists of telemetry from sessions of different users; e.g., video-watching sessions. Other examples could be user sessions in a mobile application or network flows or TCP sessions. Each session is annotated with a set of attributes that describe the user or the session; e.g., user location, ISP, device information, etc. Each session is associated with a set of per-session KPIs for each epoch of measurement; e.g., per-minute QoE metrics like buffering time, bitrate, etc. Sessions are grouped into cohorts based on the attributes of the session. A cohort is a group of sessions that have the same set of attributes. For example, a cohort could be sessions from a specific location or all sessions from a specific ISP. In our experiments, we observe 300 to over one million cohorts based on the dataset. Operational tasks are often interested in analyzing the metrics at a cohort-level granularity to see global patterns of good/bad performance. Hence, we can aggregate the session measurements, called session metrics, of all sessions in a cohort to get the cohort summary metrics (referred to as metrics ). Example cohort metrics could be the average buffering time of all sessions in a cohort. Figure 2 . Data setting for Alternative history analysis. users require aggregate statics of arbitrary user cohorts across any time-step in the past. 2.1.2. Need for alternative history analysis While such operational data is used for real-time detection of anomalies and forecasting, our discussions with operators, algorithm developers, and MLOps practitioners revealed a more fundamental pain point. In essence, operational systems are constantly in a state of flux due to workload changes, algorithm developments, and customer asks. Consequently, there are numerous use cases that require operators and analysts to access and query longitudinal data as part of everyday operations. Most of the queries can be formulated as a function that derives aggregate statistics and compute predictions on them from the session metrics of a cohort. Formally, let \mathbf{m} be the vector of session metrics at a specific time-step t . and F(\mathbf{\{m_{i}\}}_{i\in S}) be function F that computes aggregate statistics across per-session metrics for the sessions in cohort S . We define cohort S as having attributes \mathcal{A}=\mathbf{a} . For example, when using Spark, we can write PySpark query to compute this statistic and to compute this metric for all cohorts, we can run this query for all possible cohorts: ⬇ 1 distinct_a = sessions . select ( "attributes" ). distinct () 2 for a_value in cohort_list : 3 filtered_df = sessions . filter ( sessions . attributes == a_value [ "attributes" ]) 4 result_df = filtered_df . select ( 5 F . col ( "attributes" ), 6 F . expr ( "F(mi_column)" ) # Apply function F, replace mi_column with actual column 7 ) Sometimes, we aggregate metrics over time: ⬇ 1 distinct_a = sessions . select ( "attributes" ). distinct () 2 for a_value in cohort_list : 3 filtered_df = sessions . filter ( 4 ( sessions . time > t1 ) & 5 ( sessions . time < t2 ) & 6 ( sessions . attributes == a_value [ "attributes" ]) 7 ) 8 result_df = filtered_df . select ( 9 F . col ( "attributes" ), 10 F . expr ( "F(mi_column)" ) # Replace ’F(mi_column)’ with the actual function you are applying 11 ) We describe examples applications as follows: \bullet What-if analysis: Operational time-series analysis needs to provide configuration knobs for users and analysts; e.g., deciding how long an anomaly should persist or how many users are affected. However, customers need data-driven guidance to understand why predictions are generated, or how changing algorithm parameters would impact the prediction accuracy, false positive rate, etc. based on historical data. For example, the function F could test if a statistic of a measurement like mean login time of an app is greater than a constant threshold. Changing the threshold or the statistic to check if certain predictions change would be a common use case. \bullet Data-centric regression test in CI/CD for MLOps: Given the constant flux in workloads and model drifts, ML engineers and algorithm developers need to refine algorithms and configurations; e.g., hyperparameter tuning as workloads or baselines change. When they do so, they need the equivalent of DevOps best practices such as regression tests . Regression test, for example, could involve testing the algorithm in F for better thresholds and parameters to optimize for accuracy for new datasets based on historical data. \bullet Algorithm selection: As new time-series methods emerge, ML teams want to continuously test out novel approaches from the research community. However, in practice, there is no one-size-fits-all, and ML teams will need to rigorously test new algorithmic approaches as well as feature engineering in their specific settings (Eg: failure rate of starting a video session) before deploying them. Testing novel algorithms and statistics required by changing the function F and tuning the model parameters could help modellers discover more performant or efficient workflows. Figure 3 . Design space for alternative history analysis: The session data is ingested and stored at each epoch of time. The user queries from the stored data across time for various tasks. AHA system computes the required features from the stored summary for the specific application. 3. Problem Formulation Given these illustrative scenarios, we formally define the problem of alternative history analytics in operational timeseries applications. We begin with some notations and definitions before deriving key requirements. Then, we discuss why canonical solutions from the literature fall short for this class of operational problems. User groups and Attributes: We formally define important aspects of the dataset. Let the dataset at time t be denoted as {\mathcal{D}_{t}} . The dataset consists of data from multiple users (usually in order of millions or tens of millions) at every time-step (minute or second). Each user is annotated with {M} attributes which describe the user-related features. In the video analytics case, these attributes can be user location, ISP, device information, etc. Formally, each user j in the dataset is characterized with {M} attributes which are initialized as {Attr_{j}}=\{{Attr_{j}[i]}\}_{i=1}^{M}\in\mathcal{A}_{1}\times\mathcal{A}_{2}\times\dots\times\mathcal{A}_{{M}} where \mathcal{A}_{i} is the space of all possible values for the attribute i . We make a reasonable assumption that each attribute can only take discrete values . Further, we record {K} metrics from each user. The metrics for user j is denoted as {\mathbf{m}_{j}}=\{{m_{j}[i]}\}_{i=1}^{K} . Therefore, the dataset at time t is {\mathcal{D}_{t}}=\{({Attr_{j}},{\mathbf{m}_{j}})\}_{j=1}^{N_{t}} where N_{t} is the number of users tracked at t . Each user group is defined by attributes common to all users in the group. A group {C({\mathbf{a}})} is defined by attribute initialization \mathbf{a}\in\mathcal{A}_{1}\cup\{*\}\times\mathcal{A}_{2}\cup\{*\}\times\dots\times\mathcal{A}_{{M}}\cup\{*\} , i.e, \mathbf{a} is a sequence of attribute values or * where * denotes that the group users can take any values. We denote \mathcal{C}_{t} to be set of non-empty groups from {\mathcal{D}_{t}} . However, the number of possible user groups is an exponential of attributes: the number of user groups is the product of the number of possible subsets of attributes times the number of possible values each of the attributes can take ( \prod_{i=1}^{{M}}(|\mathcal{A}_{i}|+1)-1 ). Therefore, we use important insights about dataset and analytics requirements to design AHA to be cost-efficient. Analytics Algorithm: For each user group {C({\mathbf{a}})} , let {\mathcal{D}_{t,\mathbf{a}}}=\{(Attr_{j},\mathbf{m}_{j}):Attr_{j}\in\mathbf{a}\} be the set of user data for all users in that group. An algorithm Alg({\mathcal{D}_{t,\mathbf{a}}};\theta) with configuration parameters \theta provides an output Alg({\mathcal{D}_{t,\mathbf{a}}};\theta)\in\mathbb{R}^{b} . For example, for the task of detecting if a given cohort is anomalous, Alg({\mathcal{D}_{t,\mathbf{a}}};\theta)\in[0,1] , i.e. it predicts the probability that a given group is anomalous. Note that {\mathcal{D}_{t,\mathbf{a}}} contains metrics data from a variable number of users, i.e., the number of users observed for any group varies across time, with many groups having very small or zero observed samples for most time-steps. We can divide the algorithm Alg() into two parts. First, we extract the required fixed set of features F({\mathcal{D}_{t,\mathbf{a}}};\theta_{F}) from the dataset {\mathcal{D}_{t,\mathbf{a}}} . These features are various statistics collected from the metrics of all the user of the group. They are usually engineered by domain experts leveraging application requirements or domain expertise. These features are further used by an analytics model \mathcal{M}(F({\mathcal{D}_{t,\mathbf{a}}});\theta_{M}) to generate the predictions for the group \mathbf{a} . The model \mathcal{M} of features can be any statistical or machine learning model. Therefore, the algorithm can be described as Alg()= where \theta=(\theta_{F},\theta_{M}) . Requirements: The goal of AHA is to support a query \mathcal{Q} of type <\mathrm{C},Alg(),\theta,T> which generate the output for a potentially new algorithm Alg( ) with hyperparameter \theta for specific groups \mathrm{G} . Conceptually, we consider candidate solution consisting of three stages: (1) Ingest and summarize the multi-group data; (2) Store the summarized data to enable a wide range of retrospective analysis; (3) Extract relevant features/information from data summary required by the analysis algorithm Alg( ). We define the following design objectives for any AH solution: \bullet Estimation Equivalence for Future Analytics: Given a family of anomaly detection algorithms Alg()\in\mathrm{Alg} , ( IngestReplay , FetchReplay ) provides task-level equivalence if (1) Alg(F({\mathcal{D}});\theta)\approx Alg(F({Repl({{\mathcal{D}}})});\theta)\forall\theta,\forall Alg()\in\mathrm{M} i.e., the estimations of the model if we use session data should be similar to estimates using the features from replay. \bullet Equivalence for Cohort metrics: Similarly, ( IngestReplay , FetchReplay ) provides cohort-level equivalence if F({\mathcal{D}})\approx F({Repl({{\mathcal{D}}})}) . Note: Methods that guarantee 100% accuracy are called strongly-equivalent solutions. These include deterministic solutions such as key-value stores, methods that accurately calculate the metrics, etc. In contrast, sampling and sketching provide approximate estimates. Such methods are called weakly-equivalent solutions. \bullet Low total cost of ownership : The total cost of ownership depends on the compute cost for ingest and replay and the storage footprint. Ideally, the size of replay data, denoted as {Repl({{\mathcal{D}}})} , should be orders of magnitude less than the raw dataset {\mathcal{D}} : |{Repl({{\mathcal{D}}})}|<<|{\mathcal{D}}|. The computational cost of using IngestReplay and FetchReplay for deriving the features for models should be similar or significantly better than directly deriving features from raw data F({\mathcal{D}}) . Limitations of related work: To tackle this challenge, we consider a few seemingly natural straw-man solutions from the literature, and discuss why they fail to satisfy our key requirements . At a high level, we can consider the design space of options as shown in Figure 3 in terms of the computation done at ingest and at query time . Within this framing, we can classify prior work that tackles multidimensional data ingestion and retrieval into approximate and precise methods. Depending on the type of precise or approximate analysis performed at ingest/query time, we can have a tradeoff with respect to the ingest, storage, and query time cost. Precise Methods: Most standard operational pipelines either compute required features from data stream at ingestion time or later during fetch. Most of these methods use a database analytics solution like Spark, Hadoop, etc ( 3 ; 13 ; 38 ) . These SQL and NoSQL databases usually compute the required features precisely and therefore provide 100% accuracy. At one end consider the option of doing nothing at ingest, storing the raw session data, and running exact queries at query time. Alternatively, rolling up aggregate statistics across multiple subgroups for each possible subpopulation may provide faster compute time, but still requires storing the entire raw data during ingest to support arbitrary queries. Both these solutions are expensive with increase in data size to store or with exponential increase in user groups as number of attributes increase as shown in our real-world applications ( 1 ) in spite of many lossless compression methods used by some of these databases. Approximate Methods: These methods compute approximation of a metric at ingest or query time usually at lower compute and memory cost . Online Sampling is a popular technique that reduces compute and latency costs ( 8 ; 34 ) . Sketch based methods provide a more efficient bounded tradeoff between memory and accuracy with sublinear complexity. These frameworks generate approximate summaries during ingest and use them to estimate statistics with apriori provable error bounds ( 27 ; 11 ; 14 ; 38 ) . Analytics databases such as Apache Druid ( 38 ) also use these approximate algorithms to compute distinct elements, histograms, etc. While these methods can provide significant savings in storage cost, they do not guarantee predictive equivalence for sample-poor user groups and scenarios and can take significant computational resources in ingesting large high-dimensional datasets. 4. AHA Design and Implementation In this section, we describe key analytical and empirically validated insights about the nature of the dataset and analytics algorithms in most applications. We use these insights to provide a practical basis for building AHA to achieve efficiency and accuracy at scale. 4.1. Main Insights Alternative history analytics queries are unpredictable over the candidate statistics and subgroups of interest. Hence, our design philosophy is that of a late binding architecture from a systems perspective. By delaying the binding of the subgroup summaries and the supported task, we argue AHA will be more cost-efficient and scalable. With this overarching design decision, we focus on the nature of the analytics tasks and datasets to identify useful properties that enable AHA to effectively store and efficiently retrieve relevant data from user subgroups. For many downstream analytics and anomaly detection tasks the required statistics F(\cdot) exhibit decomposable property, i.e., the statistic for a “parent” user group can be derived from a smaller number of statistics of “children” groups that constitute the parent group. In operational time series settings, there is a subset relationship across user groups of interest. For example, a user group corresponding to users with a specific ISP (say Comcast) could be using many CDNs for a video session. Moreover, the necessary statistics F required for most analytics algorithms can be derived from statistics of children subgroups. For example, the mean of a metric for a group of users can be derived from the mean of the metric for each of the children subgroups. This is a well-known property called decomposability (see § 4.3 . Therefore, in many cases, we can generate statistics for analytics algorithm F for “parent” group of US users from statistics collected for groups of each state. This insight enables us to 1) avoid storage-heavy solutions that need to store data for all possible subgroups, 2) narrow down the statistics we store via the replay algorithm IngestReplay for user groups, 3) choose which groups we require to store the statistics for. Figure 4 . Decomposability: Features of a group can be derived from child groups’ features. Formally, given the session dataset {\mathcal{D}_{t}} , the final set of inputs to the predictive model is a set of features for all possible subgroups \mathcal{C}_{t} . The size of \mathcal{C}_{t} is upper bounded by O(\prod_{i=1}^{{M}}|\mathcal{A}_{i}|) which is an exponential of attributes {M} . However, we can generate the necessary statistics F^{\prime} for the smallest possible set of subgroups that cover all possible subgroups called LEAF . These are subgroups where all attributes are initialized to a specific value, (i.e., Leaf({\mathcal{D}})=\{{C({\mathbf{a}})}:\mathbf{a}\in\mathcal{A}_{1}\times\mathcal{A}_{2}\times\dots\times\mathcal{A}_{{M}}\} ). Let \mathcal{A}_{t}\subseteq{Attr_{1}}\times{Attr_{2}},\dots,\times{Attr_{{M}}} The AHA system therefore operates in two stages: \bullet IngestReplay stores the necessary statistics F^{\prime} of the leaf subgroups in the replay storage. (2) {Repl({{\mathcal{D}_{t}}})}={\texttt{IngestReplay}}{({\mathcal{D}_{t}})}=\bigcup_{\mathbf{a}\in\mathcal{A}_{t}}F^{\prime}({\mathcal{D}_{t,\mathbf{a}}}). \bullet FetchReplay derives required features F for any user group C(\mathbf{a}) from the intermediate features \bigcup_{\mathbf{a}^{\prime}\in Child(\mathbf{a})}F^{\prime}({\mathcal{D}_{t,\mathbf{a}^{\prime}}}) where Child(\mathbf{a}) are set of leaf groups that are contained in subgroup \mathbf{a} . (a) Number of observed leaf groups is smaller than the max. possible leaf groups (b) CUBE operation is 3-14 times faster than Groupbys across all datasets Figure 5 . Evidence for subgroup sparsity (Insights 4.1 ) and CUBE efficiency (Insight 4.1 ) Even though the number of possible subgroups can be exponential in the number of attributes {M} , in any session the number of active subgroups observed in a given time-step is much smaller. Even with the above insight 4.1 , however, the total possible number of leaf groups is still potentially exponential in the number of attributes. In practice, we observe that the number of leaf groups that appear in any given session is significantly smaller, which allows us to fit it into a single node’s memory in many cases. In fact, it is often the case that the number of active user sessions that appear in any given session is likely to fit inside a single node memory. This enables us to decouple the workflow by storing the necessary information from a much smaller number of LEAF subgroups. This process usually requires a single-node system that can efficiently process the data during IngestReplay and FetchReplay without the overhead of multi-processor communications. Therefore, we only store for LEAF groups that have been observed in the session dataset: \mathcal{A}_{t}=\{\mathbf{a}\in{Attr_{1}}\times{Attr_{2}},\dots,\times{Attr_{{M}}}||{C({\mathbf{a}})}|>0\} . The average relative number of observed leaf groups to the maximum possible number of leaf groups (Figure 5(a) ) is 0.5% to 13.7% datasets, which is small enough to fit in a machine with 64GB of memory. (a) Relative fraction of unique attribute values for different values of \alpha and number of attributes on synthetic data following Zipf distribution (b) Fraction of unique groups observed in real-world datasets over time across different sample sizes across time Figure 6 . Number of unique sessions (LEAF) increases much slower as sample size increases. We plot the relative fraction of the unique value to the total sample size for synthetic data and real data and see similar patterns of decreasing fractions. When the dataset can fit inside the resident memory of a single machine, using CUBE operations in traditional analytical databases can outperform workflows that run GROUPBY operations per subgroup in general-purpose compute engines such as Spark. A typical solution to compute statistics on subgroups on demand is via GroupBy type operations (e.g., atop Spark or SQL) on a multi-node cluster. Note, however, in AHA , our previous insight 4.1 means that we can store the necessary statistics for all leaf groups in a single node. In this setting, we can use a more efficient CUBE operator ( 17 ) . The ’CUBE’ operator in SQL and other data processing systems is a special type of GROUP BY capability that generates aggregates for all combinations of values in the selected columns. It is well studied in database and big data literature ( 23 ; 36 ) . Indeed, modern OLAP engines such as Clickhouse have native support for CUBE operations. While CUBE operations could be expensive in a distributed setting with a lot of data movements, in a single node memory resident setting it is efficient to derive the required statistics of all possible combinations of attribute values of all parent groups from the intermediate statistics of leaf groups (Figure 5(b) ). Figure 7 . AHA computes only sufficient metrics for the small number of leaf cohorts during ingest and required metrics later for other cohorts via the efficient CUBE operation. 4.2. Design and Implementation Combining the insights, we develop the following workflow for AHA consisting of two logical stages (Fig. 7 ): (1) At ingest, we compute different task-relevant metric statistics of interest per LEAF . (2) On query time, when the alternative history analysis is needed, we run a per-epoch CUBE over the per-LEAF statistics. Assume we need to compute statistics F for predictive algorithm for all cohorts. As specified in The equivalent SQL query is: (3) \text{SELECT }F(\mathbf{\{m_{i}\}}_{i\in S})\text{ FROM sessions WHERE attributes = }\mathbf{a} for all possible cohorts \mathbf{a}\in\in\mathcal{A}_{1}\cup\{*\}\times\mathcal{A}_{2}\cup\{*\}\times\dots\times\mathcal{A}_{{M}}\cup\{*\} which is exponential of attributes \mathcal{M} . Next we will convert this series of queries to a more efficient two-step process proposed in AHA with significantly better storage and compute cost. Computing LEAF metrics during ingest We compute the necessary statistics F^{\prime} of all leaf subgroups from session metric data. The corresponding query is: (4) \begin{split}&\text{CREATE VIEW {\tt leaf-table} as SELECT }F^{\prime}(\mathbf{\{m_{i}\}}_{i\in S})\\ &\text{ FROM sessions GROUP BY }(\mathcal{A}_{1},\mathcal{A}_{2},\dots,\mathcal{A}_{\mathcal{M}})\end{split} The query aggregates all the cohorts in \{\mathcal{A}_{1},\mathcal{A}_{2},\dots,\mathcal{A}_{\mathcal{M}}\} observed in the sessions . As it is much smaller than the possible number of cohorts (Insight 4.1 ), the result is a much smaller summary dataset. Generate metrics for any cohort from LEAF metrics during prediction We use the metrics of leaf groups in the leaf-table to compute sufficient statistics F^{\prime} for any cohorts. For all possible cohorts, we can use the CUBE operation available in most data processing platforms like Clickhouse and Spark as: (5) \text{SELECT }F^{\prime}(F(m))\text{ FROM {\tt leaf-table} CUBE }(\mathcal{A}_{1},\mathcal{A}_{2},\dots,\mathcal{A}_{\mathcal{M}}) Alternatively, we can also select F^{\prime} for select combinations of attributes A^{\prime}_{j}\subset\{\mathcal{A}_{1},\mathcal{A}_{2},\dots,\mathcal{A}_{\mathcal{M}}\} using grouping sets implemented in many databases as: (6) \begin{split}\text{SELECT }F^{\prime}(F(m))&\text{ FROM {\tt leaf-table} GROUP BY}\\ &\text{GROUPING SETS }(A^{\prime}_{1},A^{\prime}_{2},\dots)\end{split} This step is faster than iterating over all possible combination of cohorts due to efficient implementation of CUBE and GROUPING SETS operations in OLAP platforms (Insight 4.1 ). 1 1 1 Anonymized code: https://anonymous.4open.science/r/AHA_KDD25-3B63/ . 4.2.1. Real-time deployment details The insights above enabled successful deployment of AHA in data engineering pipelines where large amount of raw data is ingested in real-time from video sessions across major streaming providers. This is used in core data processing pipelines and alerts system to identify anomalies in time-series across all possible subgroups of users and identify the largest subpopulations and key attributes that are effected by the anomalies. The system used Clickhouse as the data processing engine and database for its efficiency on key operations like CUBE. 4.3. Soundness of AHA We characterize the kinds of statistics we can derive using our design. Let the metric data for any user at any given time be an element of set {\mathrm{M}} . The data for a subgroup of users is a finite subset of {\mathrm{M}} . A statistic is a function f:2^{{\mathrm{M}}}\rightarrow\mathrm{O} that maps metric data of a subgroup to output domain \mathrm{O} . For example, we define mean statistic as mean=\frac{1}{|{\mathcal{C}}|}\sum_{m\in{\mathcal{C}}}m which maps to a single scalar. Definition 0 (Self-decomposable statistic). Let f be a statistic. f is self-decomposable if for any finite set \mathbf{M}_{0}\in 2^{{\mathrm{M}}} and any finite disjoint partitioning of \mathbf{M}_{0} as \{\mathbf{M}_{1},\mathbf{M}_{2},\dots,\mathbf{M}_{N}\} (i.e., \mathbf{M}_{i}\cap\mathbf{M}_{j}=\phi for any 1\leq i0\} ). The replay storage consists of {Repl({{\mathcal{D}_{t}}})}=\{(\mathbf{a},F^{\prime}({\mathcal{D}_{t,\mathbf{a}}})):\mathbf{a}\in Leaf({\mathcal{D}_{t}})\} . here, F^{\prime} is the set of necessary statistics for the features F of the algorithm: F^{\prime}=\bigcup_{f\in F}N(f) . This allows us to provide a theoretical guarantee of perfect predictive equivalence with significant real-wprld storage cost reduction. Theorem 3. If the anomaly detection algorithm \mathcal{M} requires features F , all of which are decomposable, then, we can have perfect predictive equivalence by storing only the necessary statistics F^{\prime} of the leaf subgroups in the replay storage. 5. Evaluation Baselines: We compare AHA against the following alternative data-processing solutions. Strong equivalence solutions included are: \bullet StoreRaw : A common solution where we store the full raw data during ingest and fetch required features during prediction. \bullet KeyValueStore : Similar to StoreOutput , we store only the outputs via a hash map that maps the attributes of groups to stored metrics. We implement the key-value system by extending the hash-map implementation in the Rust programming language. Solutions with weak equivalence are:. \bullet Sampling : We sample a small fraction of the user samples for each time-step and fetch required statistics from the samples at fetch. \bullet Sketching : We also use a state-of-art sketching solution Hydra ( 27 ) designed for sub-population analytics uses a universal sketch to summarize summary statistics. Dataset: We evaluate AHA on multiple datasets from different applications. Statistics on the datasets are discussed in Appendix Table 2 . \bullet VideoAnalytics : Real-world user video analytics dataset observed at live deployment at a major video-streaming analytics provider . \bullet UmassTrace : Network trace dataset from ( 29 ) . \bullet NYTaxi : Contains the pickup and dropoff times and other statistics provided by New York Taxi and Limousine Commission ( 35 ) . \bullet CH-Bench : Anonymized DB log traces data provided by Clickhouse \bullet MGBench : Synthetic benchmark from ( 5 ) originally intended to test GPU performance on data i/o and simple computational workflows \bullet IMDB : Dataset from IMDB containing a list of movies and various features including year of release, actors, language, etc. Benchmarking details We analyze the ability of AHA and baselines to support standard prediction pipelines. We consider anomaly detection algorithms used in production: standard deviation thresholds, k nearest neighbors ( KNN ) ( 2 ) and Isolation Forest ( IsoForest ) ( 25 ) . All these algorithms use mean of the metrics observed across the users as features. We measure the fidelity of each of the baselines by measuring both the accuracy of the aggregate metric (metric accuracy) and of the anomaly detection algorithm (task accuracy). Metric accuracy is measured as RMSE score and task accuracy as classification accuracy of anomalies. Note that the accuracy here refers to how closely the predictions derived from a given system matches the predictions using raw data. Methods that compute the metrics precisely including AHA will have 100% accuracy while approximate methods may have lower accuracy. To determine the total cost of the system (compute and storage), we measure the cost of performing this operation over a period of a month on a EC2 system of similar configuration via AWS using S3 to store the summarized data for each solution. We provide more details on the setup, cost model and parameter settings of the baselines in Appendix § B . (a) Cost vs Metric accuracy (b) Cost vs Task accuracy Figure 8 . Normalized Cost for different minimum task and metric accuracy requirements. AHA is 55-130 times more efficient among strong equivalence solutions and the cheapest solutions for all datasets with over 80% metric accuracy requirement. AHA is lowest cost across all task accuracy requirements (> 90%) with 8.6-87 times lower cost. Figure 9 . Percentage of storage of raw data. AHA has the lowest storage requirements over other solutions. 5.1. Results Accuracy and Cost trade-off: We show the cost vs. accuracy (fidelity) trade-off in Fig. 1 and 8 for VideoAnalytics and others in the Appendix Fig. 13 . First, we observe, as expected that AHA , StoreRaw , KeyValueStore and StoreOutput show 100% fidelity. Sampling has an average accuracy of 71% whereas Sketching has an average accuracy of 88%. Further, the approximation methods have large variance in accuracy across groups and time. The 90 percentile average accuracy of Sampling and Sketching are 27% and 53% respectively. AHA provides 34-85 times lower cost than the standard solutions of storing raw data or outputs features. It also provides 6-10 times lower cost than Sketching . Since the compute cost per hour is costlier than the storage cost per GB per month, the storage cost is 3-4 orders of magnitude lower than the compute cost. We measure the average reduction in storage in Fig. 9 . Scalability of AHA : We study the scalability of AHA and other solutions along two aspects. First, we study the effect of an increase in the number of subgroups and user attributes. This increases the number of leaf groups and the complexity of the CUBE operation. Approximation methods also include an increase in the number of groups with a smaller number of samples. We use the synthetic data Synth where the attributes are generated using a Zipf’s distribution which mimics the average distribution of attributes in VideoAnalytics . We let the number of user samples be the same as VideoAnalytics and arbitrarily increase the number of attributes to simulate the case where we have access to a larger number of user attributes, a common situation in video analytics. (a) Scalability for accuracy (b) Scalability for cost Figure 10 . AHA provides cost scalability with increase in attributes while maintaining perfect accuracy. The accuracy of approximate methods decreases with an increase in attributes (Fig. 10(a) ) due to an increase in low sample groups. The compute cost is two orders of magnitude lower than other perfectly accurate solutions as well as significant lower than sketching-based solution. AHA scales horizontally with no. of workloads. We measure the scalability across multiple parallel workloads such as when we have to perform analytics for many customers simultaneously. We measure the total cost as we increase the number of parallel workloads running each task on a node. AHA scales better with an increase in the number of workloads than other perfect replay solutions as well as the sketching solution (Fig. 11 ). Figure 11 . Cost over the number of workloads. AHA scales efficiently with the number of workloads. 5.2. Deployment Experience We showcase the practical effectiveness of AHA by providing a detailed study of one of the core application in production. The application involves user journey analytics on a mobile application used to stream video data. This study evaluates preprocessing and analytics performance tracking user navigation patterns. Setup: While the total production dataset involves ingesting and processing hundreds of GB of data per minute, we look at a subset of dataset that focus on 10 user attributes measured over 30 days. We analyze a 30-day subset of production data focusing on 10 user attributes. This subset contains 26.17 GB of logs across 95,408,549 user sessions. We evaluate three key user engagement metrics: (i) successful seek operations, defined as playback resumption after a user-initiated seek, (ii) the number of recommended videos on the homepage that were played, and (iii) the number of carousel suggestions clicked. The quality of experience (QoE) metric counts these successful operations, grouped per minute during preprocessing. Since the metric of interest is the total number of operations per user group, we sum them across sessions—a decomposable operation that AHA optimizes. Unlike the baseline’s repeated single-purpose aggregations using GROUP BY on raw data, AHA uses a two-phase approach: creating a LEAF table with decomposable statistics (sum + count), followed by efficient CUBE-like roll-ups from pre-computed statistics rather than rescanning raw data. Performance comparison. AHA achieves a 1.25 \times speedup in per-minute data aggregation while producing identical output (45,454 cohorts). For the entire data, AHA completed the operation in 2:30 hrs, while the baseline needed 3:08 hrs. For downstream regression analysis using QoE metrics, AHA demonstrates significant performance improvements on the processed data. Both methods achieve identical model quality (R² = 0.97), but AHA ’s optimized data representation enables 6.2 \times faster query execution. This performance gain becomes crucial when scaling to such large scale datasets. This example validates that AHA maintains analytical accuracy while providing substantial performance improvements in both data preprocessing and query execution phases of the analytics pipeline. 6. Conclusions Operational timeseries problems, characterized by high data volume, cardinality, and constant change, force practitioners to compromise cost and fidelity in retrospective analytics. This paper addresses these challenges by proposing a practical and rigorous solution: AHA . AHA offers a practical alternative where we can achieve both cost efficiency and perfect accuracy by leveraging structural characteristics of the data, query workloads, and modern analytical databases. Our experiments and case-study shows AHA provides 34-85 times less total cost of ownership without any loss in accuracy which translates to a cost savings of over $0.7M per month. We observed about 75% cost savings for important applications we deployed We believe our work is a first but significant step in identifying and tackling a practical operational problem of alternative history analytics. Acknowledgements: This work was supported in part by NSF (Expeditions CCF-1918770, CAREER IIS-2028586, Medium IIS-1955883, Medium IIS-2403240, Medium IIS-2106961, PIPP CCF-2200269), NIH (1R01HL184139), CDC MInD program, Meta faculty gifts, Dolby gift and funds/computing resources from Conviva and Georgia Tech. Supplementary for the paper " AHA : Scalable Alternative History Analysis for Operational Timeseries Applications" Appendix A Applicability of AHA to different algorithms One trivial sample statistic that can be used to derive any sufficient statistic is the set of user data samples themselves (i.e. we store simply store the full raw dataset). However, due to storage cost, we cannot support such algorithms ( 26 ; 37 ) that need to ingest all the samples. We, therefore, review commonly used sample statistics and characterize their decomposability and applicability to AHA framework. We can calculate the mean of any parent subgroup by using the count and sum of children subgroups which are self-decomposable. Therefore, we can support the mean for any subgroup. We cannot accurately calculate the median of the subgroup population without all the samples. However, there are reliable approximation algorithms that involve storing frequency values of histograms of the samples ( 31 ) . A similar method can also be used to approximate estimates of sample quantiles and percentiles. Variance and standard deviation of a sample can be estimated from the mean, count, and sum of squares all of which are decomposable. Similarly, we can calculate higher-order moments by tracking the sum of sample values raised to appropriate exponents. Similar to median and quartiles, we cannot accurately estimate the interquartile range but can leverage approximate estimates of quartiles. Since maximum and minimum are self-decomposable statistics, we can accurately estimate the range. Most standard benchmarks for standard temporal anomaly detection do not make any assumptions on the type of features used for generating the time-series or use simple statistics like mean or sum of observations from a group of sensors ( 12 ) . Appendix B Benchmark Setup Details We evaluate all the baselines on a standard compute setup consisting of a 64-core Intel Xeon CPU and 256 GB of available main memory. The input data is stored as a parquet file on the single node for each time step. The summarized data is stored as a compressed CSV file for AHA (we use the fast zstd compression). To fetch the relevant statistics for prediction the CSV file is extracted, and then we roll up to evaluate the statistics for the required groups. B.0.1. Anomaly detection algorithms: To analyze the ability of AHA and baselines to support a wide range of prediction pipelines we consider different anomaly detection algorithms. We use three diverse anomaly detection algorithms that are being used widely in research and practice ( 7 ; 9 ; 19 ) . We first evaluate with a simple baseline that detects if any metric’s average value is 3 standard deviations away from the historical mean ( 3Sigma ) ( 33 ) . Finally, we use two other popular anomaly detection algorithms: k nearest neighbors ( KNN ) ( 2 ) and Isolation Forest ( IsoForest ) ( 25 ) . All these algorithms use mean of the metrics observed across the users as features to detect the anomalies. We do not choose complex neural algorithms since the time required to compute the anomalies far exceeds the time for the replay system to ingest, store and fetch the data. However, they also use similar statistics used by these algorithms. We show the results for the average accuracy of three tasks here since they are observed to be very similar to each other. Moreover, over 99% of the total cost is due to ingesting and fetching group statistics for all three tasks. B.0.2. Evaluation metrics: We measure the fidelity of each of the baselines by measuring both the accuracy of the aggregate metric (metric accuracy) as well as the accuracy of the anomaly detection algorithm (task accuracy). We measure metric accuracy via the RMSE score and task accuracy via the classification accuracy of anomalies. Since AHA has perfect recall of the required statistics for decomposable statistics, we expect the agreement accuracy to be 100% for both the metric and the algorithm predictions, as are other perfect recall solutions: StoreRaw , StoreOutput , KeyValueStore . Due to approximations of Sampling and Sketching , there may be reduction in metric and task accuracy of these solutions. We measure the average accuracy across time and across all user subgroups. We also measure the variance in accuracy across subgroups since subgroups with small samples are particularly vulnerable to mispredictions by these methods. B.0.3. Cost Model: To determine the total cost of the system (compute and storage), we measure the cost of performing this operation over a period of a month on a EC2 system of similar configuration via AWS using S3 to store the summarized data for each solution. We measured the total compute time and multiplied it with cost of compute ($0.96 per hour) and similarly calculated the total storage cost by calculating the cost per GB ($0.15 per month). The combined cost is measured. We report the normalized cost which is the total cost divided by the cost of the default typical big data architecture solution StoreRaw e.g. Spark. B.0.4. Calibrating hyperparameters for weak equivalence models: Weak equivalence methods have hyperparameters that determine the tradeoff between accuracy and cost of the solution. Sampling has a hyperparameter k which is the percentage of samples to be stored. Similarly, Sketching has a hyperparameter s which is the size of the sketch. The size of the sketch is the number of hash functions used in the sketch times the number of buckets in the sketch. We tune the number of hash functions of Sketching . We tune the hyperparameters based on user requirements defined by parameters ( \delta,\epsilon ) where \delta is the percentage of groups that can have an error of at most \epsilon . By default we set \delta=0.95 and tune for different \epsilon to determine the cost trade-off. Dataset VideoAnalytics UmassTrace NYTaxi CH-Bench MGBench BigData Attributes 12 3 2 32 4 31 Metrics 7 1 8 11 15 7 Avg. # groups 1303562 344 513 28711 722 119552 Timesteps 1081 2351 730 7116 271 1998 Total size (GB) 1667 48 2463 17.2 31.5 117.8 Table 2 . Datasets statistics (a) BigData (b) CH-Bench (c) VideoAnalytics (d) MGBench (e) UmassTrace (f) NYTaxi Figure 12 . Normalized Cost for different datasets for different minimum task accuracy requirements. AHA is the only solution with the lowest cost across all accuracy requirements (> 90%) with 8.6-87 times lower cost. Also note that for accuracy > 97% weak-equivalence methods cost more than even storing full session data showcasing compute overhead of sampling and sketching methods for high accuracy prediction. (a) BigData (b) CH-Bench (c) VideoAnalytics (d) MGBench (e) UmassTrace (f) NYTaxi Figure 13 . Normalized Cost for different datasets for different minimum metric accuracy requirements. AHA is the only solution with the lowest cost. AHA is 55-130 times more efficient among strong equivalence solutions and are the cheapest solutions for all datasets with over 80% accuracy requirement.