# Querying \[old, deprecated]

{% hint style="success" %}
Querying Marple DB outside from Marple Insight is available to the following plans:

* Marple DB VPC
* Marple DB self-managed
  {% endhint %}

## Why query Marple DB?

Querying Marple DB directly allows you to execute advanced use cases:

* Train machine learning models
* Calculate complex aggregates
* Generate standardised reports
* ... and much more

By running these types of analysis on Marple DB, they can be 10-100x faster than traditional scripting. In those cases, the extract-load-transform (ELT) often makes it unfeasible both in terms of run time and computational demand.

By querying Marple DB, you get more value from data that is already collected, cleaned, standarised and optimised for time series operations.

## Hot storage (Postgres)

<i class="fa-key">:key:</i>  Request your database credentials from our [support team](mailto:support@marpledata.com).

### Structure

The hot storage is organised into three schemas:

1. `_mdb` contains internal bookkeeping. Touching this might cause malfunction
2. `mdb_data` has the actual time series data of heated signals. Should also not be used directly for most use cases
3. `public` contains three tables per datapool (called `default` in most cases)
   * `_dataset` with file and metadata info
   * `_signal` with signal info and metadata
   * `_signal_enum` guarantees uniqueness of signal names

<figure><img src="/files/1DcKMeyFZsX9D7Jl1em1" alt="" width="299"><figcaption></figcaption></figure>

### Querying

You can use any Postgres-compatible tool for sending queries.

For reading time series data, a premade function makes it a lot easier to get data:

<pre class="language-sql"><code class="lang-sql">-- getting data from datapool 'default'
<strong>SELECT * 
</strong><strong>FROM mdb_default_data(
</strong>    'file.csv', -- or alternatively, use dataset_id
    'speed', -- or alternatively, usesignal_id 
    0, # start timestamp (nanoseconds)
    279112 # end timestamp (nanoseconds)
)
</code></pre>

## Cold storage (Parquet)

<i class="fa-key">:key:</i> Request your blob storage credentials from our [support team](mailto:support@marpledata.com).

### Structure

The cold storage follows a directory structure with `Datapool` > `Dataset` > `Signal` > `Parquet file` :

<figure><img src="/files/ie5EdF7OAJEg37r9x7sQ" alt="" width="375"><figcaption></figcaption></figure>

This contains the dataset name and signal names, but no other metadata.&#x20;

The actual data is stored in [parquet files](https://en.wikipedia.org/wiki/Apache_Parquet) that contain the raw time series data for one signal. If a signal contains a lot of data, it might be split across multiple parquet files (`mdb_0.parquet`, `mdb_1.parquet`, ...) that each contain a different time slice.

### Querying

Querying can be done by downloading individual Parquet files, or by writing queries in [Duck DB](https://duckdb.org/) (or similar tools).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.marpledata.com/docs/marple-db/querying-old-deprecated.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
