Skip to content

Commit

Permalink
[update] Schema and Hypertable (#2613)
Browse files Browse the repository at this point in the history
* add a word about timestamptz over timestamp

* incorporated the review comments

Signed-off-by: Rajakavitha Kodhandapani <krajakavitha@gmail.com>

---------

Signed-off-by: Rajakavitha Kodhandapani <krajakavitha@gmail.com>
Co-authored-by: Lana Brindley <github@lanabrindley.com>
  • Loading branch information
Rajakavitha1 and Loquacity authored Sep 1, 2023
1 parent 8f9c9ca commit d7d6b85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion use-timescale/hypertables/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ To create a hypertable, you need to create a standard PostgreSQL table, and then
convert it into a hypertable.

Hypertables are intended for time-series data, so your table needs a column that
holds time values. This can be a timestamp, date, or integer.
holds time values. This can be a timestamptz, date, or integer. Ensure that you
set the datatype for the `time` column as `timestamptz` and not `timestamp`. For
more information, see [PostgreSQL timestamp][postgresql-timestamp].

<Procedure>

Expand Down Expand Up @@ -60,3 +62,4 @@ data. For more information about migrating data, see the
[create-distributed-hypertable]: /self-hosted/:currentVersion:/distributed-hypertables/create-distributed-hypertables/
[install]: /getting-started/latest/
[postgres-createtable]: https://www.postgresql.org/docs/current/sql-createtable.html
[postgresql-timestamp]: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_timestamp_.28without_time_zone.29
5 changes: 5 additions & 0 deletions use-timescale/schema-management/about-indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ data in your hypertable, you can use an index to speed up read operations. You
can create an index on any combination of columns, as long as you include the
`time` column, for time-series data. Which column you choose to create your
index on depends on what kind of data you have stored.
When you create a hypertable, set the datatype for the `time` column as
`timestamptz` and not `timestamp`.
For more information, see [PostgreSQL timestamp][postgresql-timestamp].

<Highlight type="note">
While it is possible to add an index that does not include the `time` column,
Expand Down Expand Up @@ -120,3 +123,5 @@ SELECT * FROM devices WHERE store_id = M, device_id = M, time > 10

This is an accurate query for this index. It narrows down the list to a very
specific portion.

[postgresql-timestamp]: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_timestamp_.28without_time_zone.29
6 changes: 5 additions & 1 deletion use-timescale/schema-management/about-schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ that collect varying measurements, you might need a flexible schema. In this
case, you can use PostgreSQL JSON and JSONB data types.

Timescale supports all table objects supported within PostgreSQL, including
data types, indexes, and triggers.
data types, indexes, and triggers. However, when you create a hypertable, set the
datatype for the `time` column as `timestamptz` and not `timestamp`. For more
information, see [PostgreSQL timestamp][postgresql-timestamp].

This section explains how to design your schema, how indexing and tablespaces
work, and how to use PostgreSQL constraint types. It also includes examples to
help you create your own schema, and learn how to use JSON and JSONB for
semi-structured data.

[postgresql-timestamp]: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_timestamp_.28without_time_zone.29

0 comments on commit d7d6b85

Please sign in to comment.