grafana / grafana/grafana-postgresql-datasource

Postgresql/TimescaleDB datasource - Min time interval do not take into account

Open
#153 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2
Forks
8
Avg merge
1d 21h
Merged PRs (30d)
5

Description

### What happened?

Hi all,

i have a TimescaleDB data source configured with the following options:

Image

When i try to use the $__interval variable in an SQL query:

```
SELECT
$__timeGroupAlias(ref_timestamp, $__interval),
AVG(value)
FROM database
WHERE $__timeFilter(ref_timestamp) AND tag = 'EXAMPLE'
GROUP BY time
```

it is translated to the following request in the Grafana Query Inspector:

```
SELECT
time_bucket('60.000s',ref_timestamp) AS "time",
AVG(value)
FROM database
WHERE ref_timestamp BETWEEN '2026-02-08T10:22:15.122Z' AND '2026-02-09T10:22:15.122Z' AND tag = 'EXAMPLE'
GROUP BY time
```
$__interval always return a value equal or higher than '60.000s' regardless to the selected time period.

I also try to configure a custom interval variable as following:

Image

But only value higher than 60s are displayed in the menu:

Image

PS: my dashboard did not have any query option configured:

Image

Thanks !

### What did you expect to happen?

I expect to have a minimum value of '5s' (for $__interval variable or for my custom variable) when i zoom on my data.

### Did this work before?

First time i try this.

### How do we reproduce it?

1. Create a TimescaleDB datasource with Min interval set to 5s (five seconds)
2. Create a dashboard with a $__interval time query
3. Zoom...
4. Sampling period is never lower than 60s

### Is the bug inside a dashboard panel?

Not related to the panel

### Environment (with versions)?

Grafana: Grafana v12.3.1
OS: Docker image
Browser: Chrome

### Grafana platform?

Docker

### Datasource(s)?

TimescaleDB

Contributor guide

Open the contributing guide

Research direction

Reproduce the TimescaleDB datasource query with a 5s minimum interval and inspect the generated SQL in Query Inspector while zooming the dashboard. Trace the datasource's interval handling from the $__interval and custom interval inputs; done means values below 60s, including 5s, are honored when the selected range requires them.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.