SlideShare une entreprise Scribd logo
1  sur  19
TimescaleDB:
Building a scalable
time-series
database on
PostgreSQL
Chanshik Lim
Developer at NexCloud
chanshik@gmail.com
Agenda
• Time-series Data?
• TimescaleDB Overview
• Using TimescaleDB
• Q & A
Time-series
Data?
Time-series Data? (1)
timestamp device_id cpu_1m_avg free_mem temperature location_id dev_type
2017-01-01 01:02:00 abc123 80 500MB 72 335 field
2017-01-01 01:02:23 def456 90 400MB 64 335 roof
2017-01-01 01:02:30 ghi789 120 0MB 56 77 roof
2017-01-01 01:03:12 abc123 80 500MB 72 335 field
2017-01-01 01:03:35 def456 95 350MB 64 335 roof
2017-01-01 01:03:42 ghi789 100 100MB 56 77 roof
Time-series Data? (2)
• Time-centric
• Data records always have a timestamp
• Append-only
• Data is almost solely append-only (INSERTs)
• Recent
• New data is typically about recent time intervals
Time-series Data? (3)
• Monitoring computer systems
• VM, server, container metrics (CPU, free memory, net/disk IOPS)
• Service and application metrics (request rates, request latency)
• Financial trading systems
• Classic securities, newer cryptocurrencies, payments, transaction events
• Internet of Things
• Data from sensors on industrial machines and equipment
• Eventing applications
• User/customer interaction data like clickstreams, pageviews, logins, singups
• Environmental monitoring
• Temperature, humidity, pressure, pH, pollen count, air flow, …
TimescaleDB
Overview
Easy to Use
• Full SQL interface for all SQL natively supported by PostgreSQL
• Secondary indexes
• Non time-based aggregates
• Sub-queries
• Window functions
• Connects to any client or tool that speaks PostgresSQL
• Time-oriented features
• Robust support for Data retention policies
Scalable
• Transparent time/space partitioning
• Scaling up (single node)
• Scaling out (private beta)
• High data write rates
• Right-sized chunks
• Parallelized operations across chunks and servers
Reliable
• Engineered up from PostgreSQL, packaged as an extension
• Proven foundations
• From 20+ years of PostgreSQL research
• Streaming replication
• Backups
• Flexible management options
• Compatible with existing PostgreSQL ecosystem and tooling
Architecture
• Hypertables
• Abstraction of a single continuous table across all space and time
intervals
• Chunks
• Each chunk corresponds to a specific time interval and a region of
partition key’s space
Using
TimescaleDB
Installing
• https://docs.timescale.com/latest/getting-started/installation
• Using Docker Image
• shm-size: set /dev/shm partition size
• Mapping /var/lib/postgresql/data to host directory
$ docker run -d --name timescaledb -p 5432:5432 
-e POSTGRES_PASSWORD=password 
-v /mnt/timescaledb:/var/lib/postgresql/data 
--shm-size 1G 
timescale/timescaledb:1.5.1-pg11
Setting up
$ psql -U postgres -h localhost
postgres=# create database tutorial;
CREATE DATABASE
postgres=# c tutorial
You are now connected to database "tutorial" as user "postgres".
tutorial=# create extension if not exists timescaledb cascade;
NOTICE: extension "timescaledb" already exists, skipping
CREATE EXTENSION
Creating a Hypertable
tutorial=# CREATE TABLE conditions (
tutorial(# time TIMESTAMPTZ NOT NULL,
tutorial(# location TEXT NOT NULL,
tutorial(# temperature DOUBLE PRECISION NULL,
tutorial(# humidity DOUBLE PRECISION NULL
tutorial(# );
CREATE TABLE
tutorial=# SELECT create_hypertable('conditions', 'time’,
chunk_time_interval => interval '1 day');
create_hypertable
-------------------------
(1,public,conditions,t)
(1 row)
Inserting
tutorial=# INSERT INTO conditions
tutorial-# VALUES
tutorial-# (NOW(), 'office', 70.0, 50.0),
tutorial-# (NOW(), 'basement', 66.5, 60.0),
tutorial-# (NOW(), 'garage', 77.0, 65.2);
INSERT 0 3
tutorial=# select * from conditions;
time | location | temperature | humidity
-------------------------------+----------+-------------+----------
2019-12-06 20:12:06.987648+00 | office | 70 | 50
2019-12-06 20:12:06.987648+00 | basement | 66.5 | 60
2019-12-06 20:12:06.987648+00 | garage | 77 | 65.2
(3 rows)
Querying
tutorial=# SELECT time_bucket('15 minutes', time) AS fifteen_min,
tutorial-# location, COUNT(*),
tutorial-# MAX(temperature) AS max_temp,
tutorial-# MAX(humidity) AS max_hum
tutorial-# FROM conditions
tutorial-# WHERE time > NOW() - interval '3 hours'
tutorial-# GROUP BY fifteen_min, location
tutorial-# ORDER BY fifteen_min DESC, max_temp DESC;
fifteen_min | location | count | max_temp | max_hum
------------------------+----------+-------+----------+---------
2019-12-06 20:00:00+00 | garage | 1 | 77 | 65.2
2019-12-06 20:00:00+00 | office | 1 | 70 | 50
2019-12-06 20:00:00+00 | basement | 1 | 66.5 | 60
(3 rows)
Q & A
References
• https://docs.timescale.com/latest/introduction
• https://www.youtube.com/watch?v=F-UGFSGlzsk
• https://blog.timescale.com/blog/building-columnar-compression-in-a-row-oriented-
database/

Contenu connexe

Tendances

Tendances (20)

MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
Designing data intensive applications
Designing data intensive applicationsDesigning data intensive applications
Designing data intensive applications
 
Minio Cloud Storage
Minio Cloud StorageMinio Cloud Storage
Minio Cloud Storage
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
 
[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL Tuning[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL Tuning
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
 
MongoDB performance
MongoDB performanceMongoDB performance
MongoDB performance
 
Introduction to CQL and Data Modeling with Apache Cassandra
Introduction to CQL and Data Modeling with Apache CassandraIntroduction to CQL and Data Modeling with Apache Cassandra
Introduction to CQL and Data Modeling with Apache Cassandra
 
Trino: A Ludicrously Fast Query Engine - Pulsar Summit NA 2021
Trino: A Ludicrously Fast Query Engine - Pulsar Summit NA 2021Trino: A Ludicrously Fast Query Engine - Pulsar Summit NA 2021
Trino: A Ludicrously Fast Query Engine - Pulsar Summit NA 2021
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Getting started with postgresql
Getting started with postgresqlGetting started with postgresql
Getting started with postgresql
 
IPFS: The Permanent Web
IPFS: The Permanent WebIPFS: The Permanent Web
IPFS: The Permanent Web
 
High Availability for OpenStack
High Availability for OpenStackHigh Availability for OpenStack
High Availability for OpenStack
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
 
MongoDB Administration 101
MongoDB Administration 101MongoDB Administration 101
MongoDB Administration 101
 
Oracle_Patching_Untold_Story_Final_Part2.pdf
Oracle_Patching_Untold_Story_Final_Part2.pdfOracle_Patching_Untold_Story_Final_Part2.pdf
Oracle_Patching_Untold_Story_Final_Part2.pdf
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer
 
Airflow를 이용한 데이터 Workflow 관리
Airflow를 이용한  데이터 Workflow 관리Airflow를 이용한  데이터 Workflow 관리
Airflow를 이용한 데이터 Workflow 관리
 
SOUG Day Oracle 21c New Security Features
SOUG Day Oracle 21c New Security FeaturesSOUG Day Oracle 21c New Security Features
SOUG Day Oracle 21c New Security Features
 

Similaire à pgday.seoul 2019: TimescaleDB

Developing with Cassandra
Developing with CassandraDeveloping with Cassandra
Developing with Cassandra
Sperasoft
 
Infrastructure review - Shining a light on the Black Box
Infrastructure review - Shining a light on the Black BoxInfrastructure review - Shining a light on the Black Box
Infrastructure review - Shining a light on the Black Box
Miklos Szel
 
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Hazelcast
 
Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013
Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013
Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013
it-people
 
Apache cassandra & apache spark for time series data
Apache cassandra & apache spark for time series dataApache cassandra & apache spark for time series data
Apache cassandra & apache spark for time series data
Patrick McFadin
 

Similaire à pgday.seoul 2019: TimescaleDB (20)

Re-Engineering PostgreSQL as a Time-Series Database
Re-Engineering PostgreSQL as a Time-Series DatabaseRe-Engineering PostgreSQL as a Time-Series Database
Re-Engineering PostgreSQL as a Time-Series Database
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scale
 
Owning time series with team apache Strata San Jose 2015
Owning time series with team apache   Strata San Jose 2015Owning time series with team apache   Strata San Jose 2015
Owning time series with team apache Strata San Jose 2015
 
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
 
Leveraging Cassandra for real-time multi-datacenter public cloud analytics
Leveraging Cassandra for real-time multi-datacenter public cloud analyticsLeveraging Cassandra for real-time multi-datacenter public cloud analytics
Leveraging Cassandra for real-time multi-datacenter public cloud analytics
 
Plazma - Treasure Data’s distributed analytical database -
Plazma - Treasure Data’s distributed analytical database -Plazma - Treasure Data’s distributed analytical database -
Plazma - Treasure Data’s distributed analytical database -
 
Developing with Cassandra
Developing with CassandraDeveloping with Cassandra
Developing with Cassandra
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the Cloud
 
Cassandra and Spark
Cassandra and SparkCassandra and Spark
Cassandra and Spark
 
Chicago Kafka Meetup
Chicago Kafka MeetupChicago Kafka Meetup
Chicago Kafka Meetup
 
Databases Have Forgotten About Single Node Performance, A Wrongheaded Trade Off
Databases Have Forgotten About Single Node Performance, A Wrongheaded Trade OffDatabases Have Forgotten About Single Node Performance, A Wrongheaded Trade Off
Databases Have Forgotten About Single Node Performance, A Wrongheaded Trade Off
 
Infrastructure review - Shining a light on the Black Box
Infrastructure review - Shining a light on the Black BoxInfrastructure review - Shining a light on the Black Box
Infrastructure review - Shining a light on the Black Box
 
Devops kc
Devops kcDevops kc
Devops kc
 
Speeding up R with Parallel Programming in the Cloud
Speeding up R with Parallel Programming in the CloudSpeeding up R with Parallel Programming in the Cloud
Speeding up R with Parallel Programming in the Cloud
 
Product Update: EDB Postgres Platform 2017
Product Update: EDB Postgres Platform 2017Product Update: EDB Postgres Platform 2017
Product Update: EDB Postgres Platform 2017
 
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
 
Cassandra in e-commerce
Cassandra in e-commerceCassandra in e-commerce
Cassandra in e-commerce
 
Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013
Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013
Александр Соловьев "Cassandra in-e commerce". Выступление на Cassandra conf 2013
 
Apache cassandra & apache spark for time series data
Apache cassandra & apache spark for time series dataApache cassandra & apache spark for time series data
Apache cassandra & apache spark for time series data
 
The Design, Implementation and Open Source Way of Apache Pegasus
The Design, Implementation and Open Source Way of Apache PegasusThe Design, Implementation and Open Source Way of Apache Pegasus
The Design, Implementation and Open Source Way of Apache Pegasus
 

Plus de Chan Shik Lim

Plus de Chan Shik Lim (10)

FPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpegFPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpeg
 
Improving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetricsImproving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetrics
 
Kubernetes on Premise Practical Guide
Kubernetes on Premise Practical GuideKubernetes on Premise Practical Guide
Kubernetes on Premise Practical Guide
 
Kubernetes on Premise
Kubernetes on PremiseKubernetes on Premise
Kubernetes on Premise
 
Hadoop High Availability Summary
Hadoop High Availability SummaryHadoop High Availability Summary
Hadoop High Availability Summary
 
Python Programming: Tuning and Optimization
Python Programming: Tuning and OptimizationPython Programming: Tuning and Optimization
Python Programming: Tuning and Optimization
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
Python Programming: Class and Object Oriented Programming
Python Programming: Class and Object Oriented ProgrammingPython Programming: Class and Object Oriented Programming
Python Programming: Class and Object Oriented Programming
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: Function
 
Python Programming: Type and Object
Python Programming: Type and ObjectPython Programming: Type and Object
Python Programming: Type and Object
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

pgday.seoul 2019: TimescaleDB

  • 1. TimescaleDB: Building a scalable time-series database on PostgreSQL Chanshik Lim Developer at NexCloud chanshik@gmail.com
  • 2. Agenda • Time-series Data? • TimescaleDB Overview • Using TimescaleDB • Q & A
  • 4. Time-series Data? (1) timestamp device_id cpu_1m_avg free_mem temperature location_id dev_type 2017-01-01 01:02:00 abc123 80 500MB 72 335 field 2017-01-01 01:02:23 def456 90 400MB 64 335 roof 2017-01-01 01:02:30 ghi789 120 0MB 56 77 roof 2017-01-01 01:03:12 abc123 80 500MB 72 335 field 2017-01-01 01:03:35 def456 95 350MB 64 335 roof 2017-01-01 01:03:42 ghi789 100 100MB 56 77 roof
  • 5. Time-series Data? (2) • Time-centric • Data records always have a timestamp • Append-only • Data is almost solely append-only (INSERTs) • Recent • New data is typically about recent time intervals
  • 6. Time-series Data? (3) • Monitoring computer systems • VM, server, container metrics (CPU, free memory, net/disk IOPS) • Service and application metrics (request rates, request latency) • Financial trading systems • Classic securities, newer cryptocurrencies, payments, transaction events • Internet of Things • Data from sensors on industrial machines and equipment • Eventing applications • User/customer interaction data like clickstreams, pageviews, logins, singups • Environmental monitoring • Temperature, humidity, pressure, pH, pollen count, air flow, …
  • 8. Easy to Use • Full SQL interface for all SQL natively supported by PostgreSQL • Secondary indexes • Non time-based aggregates • Sub-queries • Window functions • Connects to any client or tool that speaks PostgresSQL • Time-oriented features • Robust support for Data retention policies
  • 9. Scalable • Transparent time/space partitioning • Scaling up (single node) • Scaling out (private beta) • High data write rates • Right-sized chunks • Parallelized operations across chunks and servers
  • 10. Reliable • Engineered up from PostgreSQL, packaged as an extension • Proven foundations • From 20+ years of PostgreSQL research • Streaming replication • Backups • Flexible management options • Compatible with existing PostgreSQL ecosystem and tooling
  • 11. Architecture • Hypertables • Abstraction of a single continuous table across all space and time intervals • Chunks • Each chunk corresponds to a specific time interval and a region of partition key’s space
  • 13. Installing • https://docs.timescale.com/latest/getting-started/installation • Using Docker Image • shm-size: set /dev/shm partition size • Mapping /var/lib/postgresql/data to host directory $ docker run -d --name timescaledb -p 5432:5432 -e POSTGRES_PASSWORD=password -v /mnt/timescaledb:/var/lib/postgresql/data --shm-size 1G timescale/timescaledb:1.5.1-pg11
  • 14. Setting up $ psql -U postgres -h localhost postgres=# create database tutorial; CREATE DATABASE postgres=# c tutorial You are now connected to database "tutorial" as user "postgres". tutorial=# create extension if not exists timescaledb cascade; NOTICE: extension "timescaledb" already exists, skipping CREATE EXTENSION
  • 15. Creating a Hypertable tutorial=# CREATE TABLE conditions ( tutorial(# time TIMESTAMPTZ NOT NULL, tutorial(# location TEXT NOT NULL, tutorial(# temperature DOUBLE PRECISION NULL, tutorial(# humidity DOUBLE PRECISION NULL tutorial(# ); CREATE TABLE tutorial=# SELECT create_hypertable('conditions', 'time’, chunk_time_interval => interval '1 day'); create_hypertable ------------------------- (1,public,conditions,t) (1 row)
  • 16. Inserting tutorial=# INSERT INTO conditions tutorial-# VALUES tutorial-# (NOW(), 'office', 70.0, 50.0), tutorial-# (NOW(), 'basement', 66.5, 60.0), tutorial-# (NOW(), 'garage', 77.0, 65.2); INSERT 0 3 tutorial=# select * from conditions; time | location | temperature | humidity -------------------------------+----------+-------------+---------- 2019-12-06 20:12:06.987648+00 | office | 70 | 50 2019-12-06 20:12:06.987648+00 | basement | 66.5 | 60 2019-12-06 20:12:06.987648+00 | garage | 77 | 65.2 (3 rows)
  • 17. Querying tutorial=# SELECT time_bucket('15 minutes', time) AS fifteen_min, tutorial-# location, COUNT(*), tutorial-# MAX(temperature) AS max_temp, tutorial-# MAX(humidity) AS max_hum tutorial-# FROM conditions tutorial-# WHERE time > NOW() - interval '3 hours' tutorial-# GROUP BY fifteen_min, location tutorial-# ORDER BY fifteen_min DESC, max_temp DESC; fifteen_min | location | count | max_temp | max_hum ------------------------+----------+-------+----------+--------- 2019-12-06 20:00:00+00 | garage | 1 | 77 | 65.2 2019-12-06 20:00:00+00 | office | 1 | 70 | 50 2019-12-06 20:00:00+00 | basement | 1 | 66.5 | 60 (3 rows)
  • 18. Q & A
  • 19. References • https://docs.timescale.com/latest/introduction • https://www.youtube.com/watch?v=F-UGFSGlzsk • https://blog.timescale.com/blog/building-columnar-compression-in-a-row-oriented- database/