Skip to content

Commit 574fbdf

Browse files
billy-the-fishbilly-the-fishatovpekophilkra
authored
484 create table with start columnstore policy immediately and selecting partition column optional (#4529)
* chore: first steps for new create table. * chore: change to using CREATE TABLE with the default columnstore policy rather than add_columnstore_policy in another step. * chore: review updates. * Apply suggestions from code review Co-authored-by: Anastasiia Tovpeko <[email protected]> Signed-off-by: Iain Cox <[email protected]> * chore: update on review * chore: change includes to show new way of working * chore: update after review. * Apply suggestions from code review Co-authored-by: Philip Krauss <[email protected]> Signed-off-by: Iain Cox <[email protected]> * chore: update links --------- Signed-off-by: Iain Cox <[email protected]> Co-authored-by: billy-the-fish <[email protected]> Co-authored-by: Anastasiia Tovpeko <[email protected]> Co-authored-by: Philip Krauss <[email protected]>
1 parent f49a858 commit 574fbdf

File tree

50 files changed

+401
-733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+401
-733
lines changed

.helper-scripts/llms/generate_llms_full.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def process_imports(self, content: str, current_file_path: Path) -> str:
712712
print(f"Replaced {component_name} using default path: {default_path}")
713713

714714
# Remove or replace components that don't have clear partials
715-
orphaned_components = ['Installation', 'Skip', 'OldCreateHypertable', 'PolicyVisualizerDownsampling', 'APIReference', 'Since2180']
715+
orphaned_components = ['Installation', 'Skip', 'OldCreateHypertable', 'CreateHypertablePolicyNote', 'PolicyVisualizerDownsampling', 'APIReference', 'Since2180']
716716
for component_name in orphaned_components:
717717
# Handle both normal and spaced component tags
718718
component_tags = [

_partials/_create-hypertable-blockchain.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
1+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
22
import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intro.mdx";
33

44
## Optimize time-series data using hypertables
@@ -31,13 +31,12 @@ import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intr
3131
details JSONB
3232
) WITH (
3333
tsdb.hypertable,
34-
tsdb.partition_column='time',
3534
tsdb.segmentby='block_id',
3635
tsdb.orderby='time DESC'
3736
);
3837
```
3938

40-
<OldCreateHypertable />
39+
<CreateHypertablePolicyNote />
4140

4241
1. Create an index on the `hash` column to make queries for individual
4342
transactions faster:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
When you create a $HYPERTABLE using [CREATE TABLE ... WITH ...][hypertable-create-table], the default partitioning
2+
column is automatically the first column with a timestamp data type. Also, $TIMESCALE_DB creates a
3+
[columnstore policy][add_columnstore_policy] that automatically converts your data to the $COLUMNSTORE, after an interval equal to the value of the [chunk_interval][create_table_arguments], defined through `compress_after` in the policy. This columnar format enables fast scanning and
4+
aggregation, optimizing performance for analytical workloads while also saving significant storage space. In the
5+
$COLUMNSTORE conversion, $HYPERTABLE chunks are compressed by up to 98%, and organized for efficient, large-scale queries.
6+
7+
You can customize this policy later using [alter_job][alter_job_samples]. However, to change `after` or
8+
`created_before`, the compression settings, or the $HYPERTABLE the policy is acting on, you must
9+
[remove the columnstore policy][remove_columnstore_policy] and [add a new one][add_columnstore_policy].
10+
11+
You can also manually [convert chunks][convert_to_columnstore] in a $HYPERTABLE to the $COLUMNSTORE.
12+
13+
[add_columnstore_policy]: /api/:currentVersion:/hypercore/add_columnstore_policy/
14+
[remove_columnstore_policy]: /api/:currentVersion:/hypercore/remove_columnstore_policy/
15+
[create_table_arguments]: /api/:currentVersion:/hypertable/create_table/#arguments
16+
[alter_job_samples]: /api/:currentVersion:/jobs-automation/alter_job/#samples
17+
[convert_to_columnstore]: /api/:currentVersion:/hypercore/convert_to_columnstore/
18+
[hypertable-create-table]: /api/:currentVersion:/hypertable/create_table/

_partials/_create-hypertable-energy.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
1+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
22
import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intro.mdx";
33

44
## Optimize time-series data in hypertables
@@ -15,12 +15,11 @@ import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intr
1515
type_id integer not null,
1616
value double precision not null
1717
) WITH (
18-
tsdb.hypertable,
19-
tsdb.partition_column='time'
18+
tsdb.hypertable
2019
);
2120
```
2221

23-
<OldCreateHypertable />
22+
<CreateHypertablePolicyNote />
2423

2524
</Procedure>
2625

_partials/_create-hypertable-nyctaxis.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
1+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
22

33

44
## Optimize time-series data in hypertables
@@ -15,7 +15,6 @@ same way. You use regular $PG tables for relational data.
1515

1616
1. **Create a $HYPERTABLE to store the taxi trip data**
1717

18-
1918
```sql
2019
CREATE TABLE "rides"(
2120
vendor_id TEXT,
@@ -38,11 +37,10 @@ same way. You use regular $PG tables for relational data.
3837
total_amount NUMERIC
3938
) WITH (
4039
tsdb.hypertable,
41-
tsdb.partition_column='pickup_datetime',
4240
tsdb.create_default_indexes=false
4341
);
4442
```
45-
<OldCreateHypertable />
43+
<CreateHypertablePolicyNote />
4644

4745
1. **Add another dimension to partition your $HYPERTABLE more efficiently**
4846

_partials/_create-hypertable-twelvedata-crypto.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intro.mdx";
2-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
2+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
33

44
## Optimize time-series data in a hypertable
55

@@ -25,12 +25,11 @@ import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypert
2525
day_volume NUMERIC
2626
) WITH (
2727
tsdb.hypertable,
28-
tsdb.partition_column='time',
2928
tsdb.segmentby='symbol',
3029
tsdb.orderby='time DESC'
3130
);
3231
```
33-
<OldCreateHypertable />
32+
<CreateHypertablePolicyNote />
3433

3534
</Procedure>
3635

_partials/_create-hypertable-twelvedata-stocks.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intro.mdx";
2-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
2+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
33

44
## Optimize time-series data in hypertables
55

@@ -20,11 +20,10 @@ import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypert
2020
price DOUBLE PRECISION NULL,
2121
day_volume INT NULL
2222
) WITH (
23-
tsdb.hypertable,
24-
tsdb.partition_column='time'
23+
tsdb.hypertable
2524
);
2625
```
27-
<OldCreateHypertable />
26+
<CreateHypertablePolicyNote />
2827

2928
1. **Create an index to support efficient queries**
3029

_partials/_create-hypertable.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import HypertableIntro from "versionContent/_partials/_tutorials_hypertable_intro.mdx";
2-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
2+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
33

44
<Procedure>
55

@@ -22,11 +22,10 @@ To create a hypertable:
2222
price DOUBLE PRECISION NULL,
2323
day_volume INT NULL
2424
) WITH (
25-
tsdb.hypertable,
26-
tsdb.partition_column='time'
25+
tsdb.hypertable
2726
);
2827
```
29-
<OldCreateHypertable />
28+
<CreateHypertablePolicyNote />
3029

3130
You see the result immediately:
3231

_partials/_dimensions_info.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import OldCreateHypertable from "versionContent/_partials/_old-api-create-hypertable.mdx";
1+
import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx";
22

33
### Dimension info
44

@@ -46,12 +46,11 @@ Create a by-range dimension builder. You can partition `by_range` on it's own.
4646
temperature DOUBLE PRECISION NULL,
4747
humidity DOUBLE PRECISION NULL
4848
) WITH (
49-
tsdb.hypertable,
50-
tsdb.partition_column='time'
49+
tsdb.hypertable
5150
);
5251
```
5352

54-
<OldCreateHypertable />
53+
<CreateHypertablePolicyNote />
5554

5655
This is the default partition, you do not need to add it explicitly.
5756

@@ -152,8 +151,7 @@ CREATE TABLE conditions (
152151
temperature DOUBLE PRECISION NULL,
153152
humidity DOUBLE PRECISION NULL
154153
) WITH (
155-
tsdb.hypertable,
156-
tsdb.partition_column='time',
154+
tsdb.hypertable
157155
tsdb.chunk_interval='1 day'
158156
);
159157

_partials/_hypercore-intro-short.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ transactional capabilities.
66

77
$HYPERCORE_CAP dynamically stores data in the most efficient format for its lifecycle:
88

9+
![Move from rowstore to columstore in hypercore](https://assets.timescale.com/docs/images/hypercore_intro.svg )
10+
911
* **Row-based storage for recent data**: the most recent chunk (and possibly more) is always stored in the $ROWSTORE,
1012
ensuring fast inserts, updates, and low-latency single record queries. Additionally, row-based storage is used as a
1113
writethrough for inserts and updates to columnar storage.

0 commit comments

Comments
 (0)