-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update troubleshooting info for DISTINCT. (#3461)
* chore: update troubleshooting info for DISTINCT.
- Loading branch information
1 parent
e06b496
commit a2c10e4
Showing
2 changed files
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,49 @@ | ||
This table summarizes aggregate function support in continuous aggregates: | ||
|
||
The following table summarizes the aggregate functions supported in continuous aggregates: | ||
|
||
|Function, clause, or feature|TimescaleDB 2.6 and earlier|TimescaleDB 2.7, 2.8, and 2.9|TimescaleDB 2.10 and later| | ||
|-|-|-|-| | ||
|Parallelizable aggregate functions|✅|✅|✅| | ||
|Non-parallelizable aggregate functions|❌|✅|✅| | ||
|[non-parallelizable SQL aggregates][postgres-parallel-agg]|❌|✅|✅| | ||
|`ORDER BY`|❌|✅|✅| | ||
|Ordered-set aggregates|❌|✅|✅| | ||
|Hypothetical-set aggregates|❌|✅|✅| | ||
|`DISTINCT` in aggregate functions|❌|✅|✅| | ||
|`FILTER` in aggregate functions|❌|✅|✅| | ||
|`FROM` clause supports `JOINS`|❌|❌|✅| | ||
|
||
|
||
DISTINCT works in aggregate functions not in the query definition. For example, for the table: | ||
|
||
```sql | ||
CREATE TABLE public.candle( | ||
symbol_id uuid NOT NULL, | ||
symbol text NOT NULL, | ||
"time" timestamp with time zone NOT NULL, | ||
open double precision NOT NULL, | ||
high double precision NOT NULL, | ||
low double precision NOT NULL, | ||
close double precision NOT NULL, | ||
volume double precision NOT NULL | ||
); | ||
|
||
``` | ||
- The following works: | ||
```sql | ||
CREATE MATERIALIZED VIEW candles_start_end | ||
WITH (timescaledb.continuous) AS | ||
SELECT time_bucket('1 hour', "time"), COUNT(DISTINCT symbol), first(time, time) as first_candle, last(time, time) as last_candle | ||
FROM candle | ||
GROUP BY 1; | ||
``` | ||
- This does not: | ||
```sql | ||
CREATE MATERIALIZED VIEW candles_start_end | ||
WITH (timescaledb.continuous) AS | ||
SELECT DISTINCT ON (symbol) | ||
symbol,symbol_id, first(time, time) as first_candle, last(time, time) as last_candle | ||
FROM candle | ||
GROUP BY symbol_id; | ||
``` | ||
|
||
[postgres-parallel-agg]: https://www.postgresql.org/docs/current/parallel-plans.html#PARALLEL-AGGREGATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters