All posts

Three ScopeDB Design Principles · Part 1

Insight In No Time

TL;DR

Applications can prepare and append events directly to ScopeDB, then query the committed data for online feedback or historical analysis. Cleaning and validation stay in the application; this path needs no separate ETL pipeline.

What Slows Down Your Data Pipeline

A typical event pipeline can involve several systems:

Current Data Engineering Workflow

First, events, like user actions, are sent to the backend service via HTTP API calls. When the backend service receives these events, it processes them, turns event objects into rows with a rigid schema, and stores them into a relational database.

If the data set is small enough, developers can run analytical queries directly against the database to gain insights. However, as the data volume grows, this approach becomes increasingly difficult and inefficient. To address this, the current data engineering practices gradually introduce new components to cover different analysis needs.

A data movement platform is added to dispatch data ingestion from different sources to various processing systems. A streaming framework can be one of those processing systems to apply data cleaning, transformation, or aggregation in real-time, and then bulk load the processed data into a data warehouse or a data lake. A batch processing framework can also be introduced to handle large-scale data processing tasks that are not time-sensitive.

Each additional step in this extract, transform, and load (ETL) process introduces more complexity and potential bottlenecks, making it harder to deliver timely insights. The complexity encompasses the need for data quality checks, data schema reconciliation, and orchestration of operations across various systems.

Get Data Insights From the Beginning

ScopeDB puts event ingestion and analysis in one database. Applications can send events directly, then query the committed rows for online feedback or historical analysis.

This gives application events a direct path to analysis:

ScopeDB Data Pipeline

You may notice that the data flow of insights is now equal to transactions, rather than being a downstream consumer. Although it is still possible to capture data changes of transactions as supplementary events, the ScopeDB-powered architecture encourages users to get insights from user actions from the beginning.

Direct Append From the Application

In a pipeline built around bulk loads, events may pass through a message broker and a stream processor before reaching the analytical database. A setup using Apache Kafka, Debezium, and Apache Flink illustrates the coordination involved:

ETL Pipeline with Data Movement Platform

As shown above, building such an ETL pipeline involves numerous intermediate components, each consisting of its own storage, compute, and coordination logic. In consequence, (1) the end-to-end latency can be high even if each component is "in real-time"; (2) the operational complexity is significant; (3) the data schema among different systems must be reconciled, which is often error-prone and hits the impedance mismatch issue.

ScopeDB provides direct ingestion APIs similar to producer APIs in messaging systems. The application shapes and filters events, then the SDK batches table rows and appends them directly to ScopeDB. For this path, there is no separate ETL service to deploy or coordinate.

For example, create a table with fixed fields and an object column for variable attributes:

CREATE TABLE my_table (
    time timestamp,
    name string,
    var object
);

The application prepares rows before appending them. This Go SDK 0.7 fragment uses an existing client and request context ctx. It trims the event name and keeps variable attributes in var:

stream, err := client.Table("my_table").AppendStream(scopedb.AppendStreamOptions{})
if err != nil {
    return err
}
if err := stream.Send(ctx, map[string]any{
    "time": time.Now().UTC(),
    "name": strings.TrimSpace(" checkout "),
    "var":  map[string]any{"region": "apac"},
}); err != nil {
    _, _ = stream.Shutdown(ctx)
    return err
}
if _, err := stream.Shutdown(ctx); err != nil {
    return err
}

Send queues the row; with the default failure policy above, a successful Shutdown confirms that accepted rows are committed. Applications can validate timestamps and filter unwanted events before Send.

After the write is committed, the same rows are available for analysis:

FROM my_table
WHERE time > NOW() - 'PT1h'::interval
GROUP BY name AGGREGATE COUNT() AS event_count

The transformations live beside the code that creates the events, so normalization and filtering can evolve with the application. Append accepts the resulting table rows; ScopeQL provides queries over both their fixed fields and nested attributes. This keeps the direct path from application events to insights while avoiding another data movement system for this use case.

With just the appended row, the query returns checkout and event_count = 1: the normalized name is already available to analysis. The Go SDK guide covers connection setup, batching, and delivery handling when you put this pattern into an application.

P.S. When reads and writes share a shard-owning node, they can compete for its resources. ScopeDB separates ingestion and query compute while using shared object storage for durable data. This reduces direct CPU and memory contention; shared storage, metadata, and network limits can still affect both workloads. We'll explore this further in the following blog about adopting cloud elasticity.

Any-Shape Analysis & Exploration

Current data engineering practices involve multiple data systems to handle various types of analytical queries. Real-time serving systems are optimized for low-latency queries, while batch processing systems are designed for high-throughput data analysis. Even developers might be told to bring a time series database for time series data, a search engine for full-text search, and so on.

We have noticed that most analysis and exploration tasks can be efficiently executed in a single system, by leveraging cloud-commodity object storage as primary storage, supporting flexible data modeling, and implementing adaptive indexing strategies. This approach greatly reduces data movement/duplication between different systems.

For example, real user monitoring consists of real-time queries and historical analysis. Real-time queries are based on the latest user activities for online feedback, while historical analysis involves complex aggregations over large datasets.

Both kinds of analysis can read the same committed events in ScopeDB. The difference is how much data the query needs and how much compute it receives.

Suppose we have a simplified user actions table:

CREATE TABLE tenant.events (
    ts timestamp,
    message string,
    source string,
    application string,
    var object
);

To implement full-featured real user monitoring, users first write all the events into the tenant.events table. Then, for real-time serving, users will filter table data with multiple conditions, including time range, source, and possible conditions based on fields of var:

FROM tenant.events
SELECT *, try(var["meta"]["http_url"]::string) AS `http_url`
WHERE ts >= "2025-06-27T07:56:00Z"::timestamp
  AND ts < "2025-06-27T08:01:00Z"::timestamp
  AND NOT regexp_like(`http_url`, "/path/to/data.*")
  AND `source` = "nginx"
  AND NOT search(`http_url`, "/path/to/directory")
GROUP BY `http_url`
  AGGREGATE max(ts) AS `ts`, count() AS `cnt`
ORDER BY `ts`

Data warehouses that rely primarily on scans may struggle to execute selective queries efficiently, especially when filtering nested fields within semi-structured data. Their ability to skip irrelevant data depends on their layout, pruning, and indexing features.

However, ScopeDB's adaptive indexing system allows users to create semantic indexes on columns or expressions:

CREATE RANGE INDEX ON tenant.events (ts);
CREATE POINT INDEX ON tenant.events (ts);
CREATE POINT INDEX ON tenant.events (source);
CREATE POINT INDEX ON tenant.events (application);
CREATE SEARCH INDEX ON tenant.events (try(var["meta"]["http_url"]::string));
CREATE MATERIALIZED INDEX ON tenant.events (try(var["meta"]["http_url"]::string));

The query above can use the range index on ts to prune time ranges. The effectiveness of a search index depends on the predicate and data; a negated search may retain most rows. A materialized index on http_url can supply the extracted value without loading the entire raw var column.

On the other hand, batch processing over historical data can consume significant resources, as it often involves scanning large datasets and performing complex aggregations. Because existing real-time processing systems are generally designed for long-running jobs and store intermediate results in hot caches, it is too expensive to scale them out to handle batch workloads. Once scaled out, it isn't easy to scale them back in.

ScopeDB employs a serverless architecture where each compute node is stateless. Compute resources can scale within the available infrastructure and service limits, and ScopeDB distributes work across the participating nodes. After a query finishes, compute can be released without relocating durable data shards; the timing depends on the scaling policy and other work still in progress.

What's more, ScopeDB supports table joins, allowing users to get insights from events with additional metadata. For example, users can join the tenant.events table with a tenant.apps table to analyze app releases:

CREATE TABLE tenant.apps (
    name string,
    version string,
    release_date timestamp
);

FROM tenant.events AS e JOIN tenant.apps AS a
  ON e.application = a.name
SELECT e.*, a.name AS app_name, a.version AS app_version, a.release_date AS release_date
WHERE e.ts >= "2025-01-01T00:00:00Z"::timestamp
  AND e.ts < "2025-04-01T00:00:00Z"::timestamp
  AND e.ts >= release_date
  AND e.ts < release_date + 'PT720h'::interval
GROUP BY app_name, app_version
  AGGREGATE count() AS cnt

This counts events within 30 days after each matching release, using a half-open time window. It does not identify which version emitted an event: overlapping release windows can count the same event for multiple releases. Use a version recorded on the event when that attribution is required.

Recap: No ETL

The application-to-ScopeDB path shown here needs no separate ETL pipeline. Applications prepare rows, the SDK batches writes, and ScopeQL queries the committed data. Indexes support selective queries, while separate compute groups can serve online and batch workloads.

Validation, filtering, and delivery error handling stay in the application, alongside the code that produces the events. These steps do not require another service between the event producer and ScopeDB.

Here is how we place ScopeDB in the cloud data stack:

ScopeDB in Cloud Data Stack

Follow the quickstart to append your first events and query them.

More from the blog