11 Commits

Author SHA1 Message Date
Rafia Sabih
ff5959f8f9 Handle when FROM clause is missing in continuous aggregate definition
It now errors out for such a case.

Fixes #5500
2023-03-29 22:29:16 +02:00
Rafia Sabih
a67b90e977 Allow joins in continuous aggregates
Enable the support of having join in the query used for creating
the continuous aggregates. It has follwoing restrictions-
1. Join can involve only one hypertable and one normal table
2. Join should be a inner join
3. Join condition can only be equality
2023-01-24 19:57:24 +05:30
Sven Klemm
2d0087a0e7 Fix segfault in cagg creation
When trying to create cagg on top of any relation that is a neither
a hypertable nor a continuous aggregate the command would segfault.
This patch changes the code to handle this case gracefully and error
out when trying to create a cagg on top of a relation that is not
supported. Found by coverity.
2022-11-28 12:19:20 +01:00
Mats Kindahl
e0f3e17575 Use new validation functions
Old patch was using old validation functions, but there are already
validation functions that both read and validate the policy, so using
those. Also removing the old `job_config_check` function since that is
no longer use and instead adding a `job_config_check` that calls the
checking function with the configuration.
2022-08-25 10:38:03 +03:00
Fabrízio de Royes Mello
28440b7900 Enable ORDER BY on Continuous Aggregates
Users often execute TopN like queries over Continuous Aggregates and
now with the release 2.7 such queries are even faster because we
remove the re-aggregation and don't store partials anymore.

Also the previous PR #4430 gave us the ability to create indexes
direct on the aggregated columns leading to performance improvements.

But there are a noticable performance difference between
`Materialized-Only` and `Real-Time` Continuous Aggregates for TopN
queries.

Enabling the ORDER BY clause in the Continuous Aggregates definition
result in:

1) improvements of the User Experience that can use this so commom
   clause in SELECT queries

2) performance improvements because we give the planner a chance to
   use the MergeAppend node by producing ordered datasets.

Closes #4456
2022-07-31 15:52:55 -03:00
Fabrízio de Royes Mello
f266f5cf56 Continuous Aggregates finals form
Following work started by #4294 to improve performance of Continuous
Aggregates by removing the re-aggregation in the user view.

This PR get rid of `partialize_agg` and `finalize_agg` aggregate
functions and store the finalized aggregated (plain) data in the
materialization hypertable.

Because we're not storing partials anymore and removed the
re-aggregation, now is be possible to create indexes on aggregated
columns in the materialization hypertable in order to improve the
performance even more.

Also removed restrictions on types of aggregates users can perform
with Continuous Aggregates:
* aggregates with DISTINCT
* aggregates with FILTER
* aggregates with FILTER in HAVING clause
* aggregates without combine function
* ordered-set aggregates
* hypothetical-set aggregates

By default new Continuous Aggregates will be created using this new
format, but the previous version (with partials) will be supported.

Users can create the previous style by setting to `false` the storage
paramater named `timescaledb.finalized` during the creation of the
Continuous Aggregate.

Fixes #4233
2022-05-18 11:38:58 -03:00
Fabrízio de Royes Mello
1e8d37b54e Remove chunk_id from materialization hypertable
First step to remove the re-aggregation for Continuous Aggregates
is to remove the `chunk_id` from the materialization hypertable.

Also added new metadata column named `finalized` to `continuous_cagg`
catalog table in order to store information about the new following
finalized version of Continuous Aggregates that will not need the
partials anymore. This flag is important to maintain backward
compatibility with previous Continuous Aggregate implementation that
requires the `chunk_id` to refresh data properly.
2022-05-06 14:30:00 -03:00
gayyappan
3e042bd9dc Fix compress_chunk error message
When we have a hypertable with a cagg defined on it,
a call to the compress_chunk with the hypertable's chunk
returns an unexpected status error. Fix the error message
to return "compression not enabled"
2022-04-26 12:14:22 -04:00
gayyappan
c0050a1315 Improve error message for compress_chunk
Fix the error message for compress chunks so that it
specifies the cagg name instead of the materialized
hypertable name.
2022-01-28 10:37:08 -05:00
gayyappan
7f5c5fd10d Verify compression settings before adding policy
When a compression policy is added for a continuous
aggregate, verify that compression has been enabled, before
adding a policy.
2022-01-27 14:04:55 -05:00
Sven Klemm
5c22ef3da2 Rename continuous aggregate tests
Change the prefix for continuous aggregate tests from
continuous_aggs_ to cagg_. This is similar to commit 6a8c2b66
which did this adjustment for isolation tests because we were
running into length limitations for the spec name. This patch
adjusts the remaining tests to be consistent with the naming
used in isolation tests.
2022-01-24 14:12:56 +01:00