DashQL - Complete Analysis Workflows with SQL

André Kohn, Dominik Moritz, Thomas NeumannarXiv 2023 · DOI

Introduction

In modern data analysis, a significant gap exists between the database layer and the visualization layer. Analysts typically perform data transformations in SQL and then transition to external tools like Tableau or D3 for visualization. This separation leads to "optimization blindness," where the database remains unaware of how data will be rendered, often fetching excessive data for low-resolution displays. Furthermore, managing UI widgets and data loading across disparate systems fragments the workflow, complicating version control and collaboration.

DashQL addresses these challenges by unifying the entire analysis pipeline into a single, self-contained SQL script. By embedding data ingestion, user input, and visualization directly into the language, DashQL enables holistic optimizations that significantly enhance the performance and scalability of interactive dashboards.

An example DashQL script alongside its conceptual execution workflow.

The DashQL Language

DashQL extends the standard PostgreSQL grammar with five declarative statements designed to handle the full lifecycle of a data dashboard:

  • SET: Manages global metadata such as titles and versioning.
  • INPUT: Declares interactive UI widgets (e.g., text fields, file pickers) that supply runtime values to the script.
  • FETCH: Identifies raw data sources from protocols like HTTP or S3.
  • LOAD: Defines parsing logic for various formats, including CSV, Parquet, and JSON.
  • VISUALIZE: Specifies the output chart using a simplified syntax that compiles to Vega-Lite.
Syntax diagrams for the core DashQL language extensions.

Technical Innovations

To ensure efficiency, DashQL employs Adaptive Task Graphs. Instead of re-executing the entire script upon parameter changes, the system uses an AST-based "Patience Diff" algorithm to update only the affected tasks.

A key performance driver is the AM4 (Advanced M4) algorithm. Building on the M4 time-series aggregation method, AM4 utilizes SQL's arg_min and arg_max functions to identify extreme data points in a single pass. This ensures that visualizations remain accurate to the raw data while processing a fraction of the points. Additionally, Adaptive Materialization allows the system to choose between full file downloads or lazy fetching (e.g., HTTP range requests for Parquet) based on query requirements.

Performance and Scalability

The integration of visualization context into the SQL engine allows for automatic, lossless data reduction. For instance, if a chart is only 1,000 pixels wide, DashQL can aggregate millions of rows into a few thousand points before the data leaves the analytical engine.

Benchmarks demonstrate that the AM4 algorithm is approximately 2x faster than the state-of-the-art M4 algorithm. In tests with 500,000 tuples, AM4 computed aggregates in 22.3ms, compared to 53.7ms for M4. Furthermore, by propagating LIMIT and OFFSET requirements from table visualizations back to the fetching layer, DashQL can render initial rows of massive remote datasets almost instantaneously.

Conclusion

DashQL transforms SQL into a comprehensive UI framework for data science. By treating the browser as a database—leveraging DuckDB-Wasm for client-side execution—it eliminates the need for heavy backend infrastructure for many common tasks. While future work remains in supporting complex cross-filtering and distributed execution, DashQL provides a powerful, self-contained model for building scalable, high-performance dashboards.

Summary updated

BibTeX
@misc{kohn2023dashql,
  author = {André Kohn and Dominik Moritz and Thomas Neumann},
  title = {{DashQL - Complete Analysis Workflows with SQL}},
  year = {2023},
  eprint = {2306.03714},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.03714},
}
Figure