@@ -6,13 +6,16 @@ tags: [performance]
6
6
---
7
7
8
8
# Change hypertable chunk intervals
9
+
9
10
Adjusting your hypertable chunk interval can improve TimescaleDB performance.
10
11
This applies to both regular and distributed hypertables. For more information,
11
12
see [ best practices for time partitioning] [ best-practices ] .
12
13
13
14
## Check current setting for chunk intervals
15
+
14
16
Check the current setting for chunk intervals by querying the TimescaleDB
15
17
catalog.
18
+
16
19
``` sql
17
20
SELECT h .table_name , c .interval_length
18
21
FROM _timescaledb_catalog .dimension c
@@ -21,6 +24,7 @@ SELECT h.table_name, c.interval_length
21
24
```
22
25
23
26
The result looks like this:
27
+
24
28
``` sql
25
29
table_name | interval_length
26
30
-- ---------+-----------------
@@ -33,9 +37,11 @@ Time-based interval lengths are reported in microseconds.
33
37
</highlight >
34
38
35
39
## Change the chunk interval length when creating a hypertable
40
+
36
41
The default chunk interval is 7 days. To change this when creating a hypertable,
37
42
specify a different ` chunk_time_interval ` when calling ` create_hypertable ` or
38
43
` create_distributed_hypertable ` .
44
+
39
45
``` sql
40
46
SELECT create_hypertable(
41
47
' conditions' ,
@@ -48,8 +54,10 @@ In this example, the table to convert is named `conditions`, and it stores time
48
54
values in a column named ` time ` .
49
55
50
56
## Change the chunk interval length on an existing hypertable
57
+
51
58
To change the chunk interval on an already existing hypertable or distributed
52
59
hypertable, use the function ` set_chunk_time_interval ` :
60
+
53
61
``` sql
54
62
SELECT set_chunk_time_interval(' conditions' , INTERVAL ' 24 hours' );
55
63
```
@@ -65,4 +73,4 @@ shorten the chunk for that year. In this situation, you can create a new
65
73
hypertable and migrate your data.
66
74
</highlight >
67
75
68
- [ best-practices ] : /timescaledb/:currentVersion:/how-to-guides/hypertables/about-hypertables#best-practices
76
+ [ best-practices ] : /timescaledb/:currentVersion:/how-to-guides/hypertables/about-hypertables#best-practices-for-time-partitioning
0 commit comments