-
Notifications
You must be signed in to change notification settings - Fork 852
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
[Bug]: realtime aggregation select planning and execution time is poor #7015
Comments
@pohmelie is your timescaledb version |
@nikkhils yes, my bad. It is 2.15.1. |
@pohmelie the two queries
AND
are NOT the same. In the first query due to real time aggregation, the query that runs on the
The expected rows and actual number of rows are out of sync.
Please run |
Actually it is create table table_data (
prefix text not null,
"timestamp" timestamp with time zone not null,
value float,
constraint unique_table_data_timestamp_prefix unique (timestamp, prefix)
);
select create_hypertable('table_data', by_range('timestamp'));
create materialized view table_data_1m
with (timescaledb.continuous, timescaledb.materialized_only = false) as
select
prefix,
time_bucket('1 minute', timestamp) as timestamp,
last(value, "timestamp") as value
from table_data
group by time_bucket('1 minute', timestamp), prefix;
create index table_data_1m_prefix_timestamp
on table_data_1m (prefix, timestamp);
call refresh_continuous_aggregate('table_data_1m', null, null);
insert into table_data (prefix, timestamp, value)
select
left(md5(random()::text), 2),
'2024-01-01'::timestamptz + make_interval(secs => i / 1000.0),
random()
from generate_series(1, 10 * 60 * 1000) s(i);
call refresh_continuous_aggregate('table_data_1m', null, null);
insert into table_data (prefix, timestamp, value)
select
left(md5(random()::text), 2),
now() + make_interval(secs => i),
random()
from generate_series(1, 10 * 60 * 1000) s(i);
call refresh_continuous_aggregate('table_data_1m', '2024-06-01', null);
explain analyze select * from table_data_1m
where timestamp >= '2024-01-01'
order by timestamp asc limit 5;
ANALYZE _timescaledb_internal._materialized_hypertable_2;
explain analyze select * from _timescaledb_internal._materialized_hypertable_2
where timestamp >= '2024-01-01'
order by timestamp asc limit 5;
|
What type of bug is this?
Performance issue
What subsystems and features are affected?
Query executor, Query planner
What happened?
We faced problem that realtime aggregation select request is much heavier than request to the internal materialized view. In terms of execution it is more than 1000 times.
I read some other issues (#6976, #6321), but it looks like they solved and this one is irrelevant.
TimescaleDB version affected
2.15.1
PostgreSQL version used
16.3
What operating system did you use?
ubuntu 22.04
What installation method did you use?
Docker
What platform did you run on?
Not applicable
Relevant log output and stack trace
No response
How can we reproduce the bug?
The text was updated successfully, but these errors were encountered: