-
Notifications
You must be signed in to change notification settings - Fork 127
484 create table with start columnstore policy immediately and selecting partition column optional #4529
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
Open
billy-the-fish
wants to merge
8
commits into
515-milestone-branch-for-223-release
Choose a base branch
from
484-create-table-with-start-columnstore-policy-immediately
base: 515-milestone-branch-for-223-release
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
484 create table with start columnstore policy immediately and selecting partition column optional #4529
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
94030f6
chore: first steps for new create table.
3d0a1bd
chore: change to using CREATE TABLE with the default columnstore poli…
1118a15
chore: review updates.
28a501a
Apply suggestions from code review
billy-the-fish 31615b4
chore: update on review
billy-the-fish b33f936
chore: change includes to show new way of working
billy-the-fish 0bc6593
chore: update after review.
billy-the-fish 232a3be
Merge branch '515-milestone-branch-for-223-release' into 484-create-t…
billy-the-fish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| When you create a $HYPERTABLE using [CREATE TABLE ... WITH ...][hypertable-create-table], the default partitioning | ||
| column is automatically the first column with a timestamp data type. Also, $TIMESCALE_DB creates a | ||
| [columnstore policy][add_columnstore_policy] that automatically converts your data to the $COLUMNSTORE after an interval | ||
| that matches the default [chunk_interval][create_table_arguments]. This columnar format enables fast scanning and | ||
| aggregation, optimizing performance for analytical workloads while also saving significant storage space. In the | ||
| $COLUMNSTORE conversion, $HYPERTABLE chunks are compressed by up to 98%, and organized for efficient, large-scale queries. | ||
|
|
||
| You can customize this policy later using [alter_job][alter_job_samples]. However, to change `after` or | ||
| `created_before`, the compression settings, or the $HYPERTABLE the policy is acting on, you must | ||
| [remove the columnstore policy][remove_columnstore_policy] and [add a new one][add_columnstore_policy]. | ||
|
|
||
| You can also manually [convert chunks][convert_to_columnstore] in a $HYPERTABLE to the $COLUMNSTORE. | ||
|
|
||
| [add_columnstore_policy]: /api/:currentVersion:/hypercore/add_columnstore_policy/ | ||
| [remove_columnstore_policy]: /api/:currentVersion:/hypercore/remove_columnstore_policy/ | ||
| [create_table_arguments]: /api/:currentVersion:/hypertable/create_table/#arguments | ||
| [alter_job_samples]: /api/:currentVersion:/jobs-automation/alter_job/#samples | ||
| [convert_to_columnstore]: /api/:currentVersion:/hypercore/convert_to_columnstore/ | ||
| [hypertable-create-table]: /api/:currentVersion:/hypertable/create_table/ |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
64 changes: 64 additions & 0 deletions
64
_partials/_hypercore_create_hypertable_columnstore_policy.md
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import CreateHypertablePolicyNote from "versionContent/_partials/_create-hypertable-columnstore-policy-note.mdx"; | ||
|
|
||
| 1. **Enable $COLUMNSTORE on a $HYPERTABLE** | ||
|
|
||
| For [efficient queries][secondary-indexes], remember to `segmentby` the column you will | ||
| use most often to filter your data. For example: | ||
|
|
||
| * **$HYPERTABLE_CAPs**: | ||
|
|
||
| [Use `CREATE TABLE` for a $HYPERTABLE][hypertable-create-table] | ||
|
|
||
| ```sql | ||
| CREATE TABLE crypto_ticks ( | ||
| "time" TIMESTAMPTZ, | ||
| symbol TEXT, | ||
| price DOUBLE PRECISION, | ||
| day_volume NUMERIC | ||
| ) WITH ( | ||
| tsdb.hypertable, | ||
| tsdb.segmentby='symbol', | ||
| tsdb.orderby='time DESC' | ||
| ); | ||
| ``` | ||
| <CreateHypertablePolicyNote /> | ||
|
|
||
| * **$CAGG_CAPs** | ||
| 1. [Use `ALTER MATERIALIZED VIEW` for a $CAGG][compression_continuous-aggregate]: | ||
| ```sql | ||
| ALTER MATERIALIZED VIEW assets_candlestick_daily set ( | ||
| timescaledb.enable_columnstore = true, | ||
| timescaledb.segmentby = 'symbol' ); | ||
| ``` | ||
| Before you say `huh`, a $CAGG is a specialized $HYPERTABLE. | ||
|
|
||
| 1. Add a policy to convert $CHUNKs to the $COLUMNSTORE at a specific time interval: | ||
|
|
||
| Create a [columnstore_policy][add_columnstore_policy] that automatically converts $CHUNKs in a $HYPERTABLE to | ||
| the $COLUMNSTORE at a specific time interval. For example: | ||
| ``` sql | ||
| CALL add_columnstore_policy('assets_candlestick_daily', after => INTERVAL '1d'); | ||
| ``` | ||
|
|
||
| $TIMESCALE_DB is optimized for fast updates on compressed data in the $COLUMNSTORE. To modify data in the | ||
| $COLUMNSTORE, use standard SQL. | ||
|
|
||
|
|
||
| [job]: /api/:currentVersion:/actions/add_job/ | ||
| [alter_table_hypercore]: /api/:currentVersion:/hypercore/alter_table/ | ||
| [compression_continuous-aggregate]: /api/:currentVersion:/continuous-aggregates/alter_materialized_view/ | ||
| [convert_to_rowstore]: /api/:currentVersion:/hypercore/convert_to_rowstore/ | ||
| [convert_to_columnstore]: /api/:currentVersion:/hypercore/convert_to_columnstore/ | ||
| [informational-views]: /api/:currentVersion:/informational-views/jobs/ | ||
| [add_columnstore_policy]: /api/:currentVersion:/hypercore/add_columnstore_policy/ | ||
| [hypercore_workflow]: /api/:currentVersion:/hypercore/#hypercore-workflow | ||
| [alter_job]: /api/:currentVersion:/actions/alter_job/ | ||
| [remove_columnstore_policy]: /api/:currentVersion:/hypercore/remove_columnstore_policy/ | ||
| [in-console-editors]: /getting-started/:currentVersion:/run-queries-from-console/ | ||
| [services-portal]: https://console.cloud.timescale.com/dashboard/services | ||
| [connect-using-psql]: /integrations/:currentVersion:/psql/#connect-to-your-service | ||
| [insert]: /use-timescale/:currentVersion:/write-data/insert/ | ||
| [hypertables-section]: /use-timescale/:currentVersion:/hypertables/ | ||
| [hypertable-create-table]: /api/:currentVersion:/hypertable/create_table/ | ||
| [hypercore]: /use-timescale/:currentVersion:/hypercore/ | ||
| [secondary-indexes]: /use-timescale/:currentVersion:/hypercore/secondary-indexes/ |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,8 +1,16 @@ | ||
| For $TIMESCALE_DB v2.23.0 and higher, the table is automatically partitioned on the first column in the table with a | ||
| timestamp data type. For earlier versions, set `partition_column` to a time column. | ||
|
|
||
| If you are self-hosting $TIMESCALE_DB v2.20.0 to v2.22.1, to convert your data to the $COLUMNSTORE after a specific time | ||
| interval, you have to call [add_columnstore_policy] after you call [CREATE TABLE][hypertable-create-table] | ||
|
|
||
| If you are self-hosting $TIMESCALE_DB v2.19.3 and below, create a [$PG relational table][pg-create-table], | ||
| then convert it using [create_hypertable][create_hypertable]. You then enable $HYPERCORE with a call | ||
| to [ALTER TABLE][alter_table_hypercore]. | ||
|
|
||
|
|
||
| [pg-create-table]: https://www.postgresql.org/docs/current/sql-createtable.html | ||
| [create_hypertable]: /api/:currentVersion:/hypertable/create_hypertable/ | ||
| [alter_table_hypercore]: /api/:currentVersion:/hypercore/alter_table/ | ||
| [add_columnstore_policy]: /api/:currentVersion:/hypercore/add_columnstore_policy/ | ||
| [hypertable-create-table]: /api/:currentVersion:/hypertable/create_table/ | ||
| [chunk_interval]: /api/:currentVersion:/hypertable/set_chunk_time_interval/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.