# TimescaleDB & PostgreSQL

Marple supports [**TimescaleDB**](https://www.timescale.com/) **and** [**PostgreSQL**](https://www.postgresql.org/)**,** making it ideal for structured and time-series data.

### Required credentials

To set up a connection, you need:

* Database URL
* Port (`5432` by default)
* Database name
* Username
* Password

### Queries

Queries are executed using SQL. Marple offers predefined queries for fetching datasets, signals, and time-series data. Below are some example queries:

* **dataset list**

```sql
select
    concat("carId", ' ', session) as display_name,
    "carId",
    event,
    session,
    min(time) as start,
    max(time) as stop,
    realtime
  from {{TABLE}}
  where time between {{TABLE}}.start and {{TABLE}}.stop
  group by "carId", event, session, realtime

```

* **signal list**

```sql
select 
  name,
  sum(count) as count,
  max(count):: double precision *(1e9) as frequency
from {{TABLE}}
where "carId" = '{{ dataset.carId }}'
group by name

```

* **time series**

```sql
select time / 1e9 as "timestamp", value
from {{TABLE}}
where "carId" = '{{ dataset.carId }}'
{%- if timestamp_start %}
and ({{timestamp_start}} * 1e9)::bigint <= time
{%- endif %}
{%- if timestamp_stop %}
and ({{timestamp_stop}} * 1e9)::bigint >= time
{%- endif %}
and name = '{{ signal.name }}'

```


---

# 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-insight/setup-and-configuration/data-connection/supported-databases/timescaledb-and-postgresql.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.
