raintank / crate-datasource

Apache License 2.0
13 stars 8 forks source link

time grouping applies to large limit, doesn't use the database functions for "normal" grouping intervals #42

Open jodok opened 7 years ago

jodok commented 7 years ago

if i select data for the last half year the datasource generate this query:

"SELECT floor(timestamp/86400000)*86400000 as time, count(*) FROM \"dashboard\".\"udc\" WHERE timestamp >= ? AND timestamp <= ? GROUP BY time ORDER BY time ASC LIMIT 5180400000"

it should use:

"SELECT date_trunc('day') as time, count(*) FROM \"dashboard\".\"udc\" WHERE timestamp >= ? AND timestamp <= ? GROUP BY time ORDER BY time ASC LIMIT 182"

(or more than 182 - but half a year has only 182 days).

alexanderzobnin commented 7 years ago

@jodok you should use Auto interval, not Auto (grafana).