-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TimescaleDB continuous aggregation wrong time buckets #5864
Comments
Thanks for reporting @Sanprof! |
@Sanprof I've been able to reproduce the case and now trying to understand if this a bug. I see that you are using origin timestamp set as The question is, is it necessary for you to specify date and time? |
@pmwkaa thanks for you response. In this sample I wanted describe that for us extremally important to aggregate data with the condition
The result is wrong and currently we are using our own function to selecting aggregated data from raw data table
And avg values are correct for us |
We have changed the continuous aggregation time bucket to 1 minute and here is what we can see on the live example. We have 1 critical incident because of higher temperature happened at 04:48:52, and because of the wrong time bucket in the materialized view the calculated temperature index = 0 and is belong to 04:48:00 but has to belong to 04:49:00 because the critical issue happened after 04:48:00 and before 04:49:00. This is should be very critical, especially for time metrics to clearly understand when the issue has happened. I'm curious why nobody (I mean users who are using continuous aggregation) didn't think about such a wrong calculation. |
Hello @Sanprof, My understanding is that being able to use this version of time_bucket:
would meet your requirements, is that right? |
Hello @konskov, The majority issue for us is that
Unfortunately, for now, we cannot use continuous aggregation while the time bucket has the incorrect time. But in any case when you have the possibility to override this function or we can use something similar to our |
+1, This might be related to #5806 |
@Sanprof Thank you for the report. This looks like a duplicate of #5806 so closing it in favor of that issue. I think there are two possible solutions: either implement a right-closed, left-open version of Right now, we have an internal cache that marks functions as "ok", but one possible extension is to expose this as a table and allow any functions to be registered there. I added a note to #5806 about this. |
Relevant system information:
SELECT version();
): PostgreSQL 15.2, compiled by Visual C++ build 1914, 64-bit\dx timescaledb_toolkit
inpsql
): timescaledb 2.10.3Describe the bug
We have a device for temperature collecting, it is configured to collect the temperature of the refrigerator box each second in the buffer (but can collect even fewer periods 10ms, 100ms) and at the end of each minute it sends an average value for the last minute (but it can be required to send average temperature per each second or per every 10 seconds). We have a hyper_table for these data. And we want to create some amount of continuous aggregation (with required intervals but for now it is 5min) for this table as it grows continuously. The issue we faced during the creation of materialized view is that the time_bucket function uses the date_bin function which always uses the start_date as basis. It means that time_bucket will always use the next statement
time >= start_date and time < end_date
which is wrong for us because we needtime > start_date and time <= end_date
. I tried to usetimescaledb_experimental.time_bucket_ng
with origin parameter and it seems it works incorrectlyTo Reproduce
Expected behavior
Actual behavior
I have also incorrect results when I use time_bucket without origin parameter and time has type timestamptz
The text was updated successfully, but these errors were encountered: