SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Managing Temporal Data in PostgreSQL
Anton Dignös
Free University of Bozen-Bolzano
SFScon 2022
November 11, 2022
AUTONOME
PROVINZ
BOZEN
SÜDTIROL
PROVINCIA
AUTONOMA
DI BOLZANO
ALTO ADIGE
Research Südtirol/Alto Adige 2019
Project ISTeP
CUP: I52F20000250003
EFRE 2014-2020
Project EFRE1164 PREMISE
CUP: I59C20000340009
Agenda
What is temporal data?
Period temporal data in Postgres
Time series data in Postgres
What are we working on?
This talk will only provide a glimpse, if you are interested in more details,
I am happy to talk to you during the conference!
SFScon 2022 2/22 A. Dignös
Temporal data
Temporal data can be found in many application
▶ HR contracts
▶ Insurance policies
▶ Tourism data
▶ Medical domain
▶ Stock market data
▶ Industrial data
SFScon 2022 3/22 A. Dignös
What is temporal data?
Data with a “timestamp”
+
The “timestamp” indicates the validity of the data
Examples:
▶ A contract with a validity period
▶ A sensor reading with the measurement time
▶ An error event with the happening time
SFScon 2022 4/22 A. Dignös
Basic utilities for date/time in Postgres
▶ Postgres provides different date/time datatypes1
▶ Many functions
▶ Operators (+, -)
▶ Calendar functions (EXTRACT, date trunc)
▶ Whoever worked with dates/timezones knows to appreciate these
1
https://www.postgresql.org/docs/current/datatype-datetime.html
SFScon 2022 5/22 A. Dignös
Topic of today
Today it is about temporal data, not just storing dates or time
▶ Period temporal data
▶ Contracts
▶ Manufacturing periods
▶ Error states
▶ Time series data
▶ Sensor readings
▶ Stock market data
▶ Error events
Let’s have a peek on what Postgres and it’s ecosystem has to offer!
SFScon 2022 6/22 A. Dignös
Highlights for period temporal data in Postgres
▶ Postgres provides range types2 for managing period data
▶ What are range types?
▶ Datatypes for periods ’[start, end)’
▶ Can have different forms – ’[ , )’,’[ , ]’, ’( , ]’, ’( , )’
▶ Available for different types, e.g., INT, NUMERIC, DATE
▶ Many predicates and functions
▶ Indices available (GiST, SP-GiST, btree gist)
▶ Very easy to use
▶ Avoid many programming mistakes
2
https://www.postgresql.org/docs/current/rangetypes.html
SFScon 2022 7/22 A. Dignös
An example
Product prices that change over time
CREATE TABLE prices(
product INT ,
period DATERANGE ,
value FLOAT );
INSERT INTO prices
VALUES (1, ’[2021 -08 -01 ,␣2022 -08 -01) ’, 25),
(1, ’[2022 -08 -01 ,) ’, 30),
(2, ’[2021 -08 -01 ,␣2022 -04 -01) ’, 10),
(2, ’[2022 -04 -01 ,) ’, 20);
product | period | value
---------+-------------------------+-------
1 | [2021-08-01,2022-08-01) | 25
1 | [2022-08-01,) | 30
2 | [2021-08-01,2022-04-01) | 10
2 | [2022-04-01,) | 20
SFScon 2022 8/22 A. Dignös
Common queries
▶ What are the prices of products today?
WHERE period @> CURRENT_DATE
▶ What were the prices of products on the 2021-10-30?
WHERE period @> ’2021 -10 -30 ’
▶ What were the previous prices of products?
WHERE period << daterange(CURRENT_DATE , NULL , ’[)’)
▶ What were the prices of products between 2021-10-30 and
2022-10-30?
WHERE period && DATERANGE(’2021 -10 -30 ’,’2022 -10 -30 ’, ’[]’)
SFScon 2022 9/22 A. Dignös
Uniqueness Constraints
Ensure a product does not have two prices at the same time
CREATE TABLE prices(
product INT ,
period DATERANGE ,
value FLOAT ,
EXCLUDE USING GIST (product WITH =, period WITH &&));
product | period | value
---------+-------------------------+-------
1 | [2021-08-01,2022-08-01) | 25
1 | [2022-08-01,) | 30
2 | [2021-08-01,2022-04-01) | 10
2 | [2022-04-01,) | 20
INSERT INTO product_prices VALUES (1, ’[2022 -08 -04 ,) ’, 100);
ERROR: conflicting key value violates exclusion constraint ...
DETAIL: Key (product, period)=(1, [2022-08-04,)) conflicts ...
SFScon 2022 10/22 A. Dignös
Take home messages
▶ Range types is Postgres’ native period datatype
▶ Convenient representation of periods
▶ Many base datatypes are supported
▶ Support different period definitions if needed
▶ Many convenient predicates and functions
▶ Less error prone than custom builds
▶ Can be speed up using GiST indices
▶ Uniqueness constraints available
▶ Avoid inconsistencies at the source
SFScon 2022 11/22 A. Dignös
Highlights for time series data in Postgres
▶ TimescaleDB can be used to manage time series in Postgres
▶ What is TimescaleDB?
▶ TimescaleDB is a Postgres extension (based on UDFs)
▶ Runs on server side
▶ License (two versions of TimescaleDB with different support)3
▶ TimescaleDB Apache 2 Edition (Apache 2.0 license)
▶ TimescaleDB Community Edition (Timescale License – TSL)
▶ See https://docs.timescale.com/timescaledb/latest/
timescaledb-edition-comparison
▶ Available for most platforms as a binary or compile form source
3
Thanks to Chris Mair from 1006.org for pointing this out during a previous talk!
SFScon 2022 12/22 A. Dignös
What does TimescaleDB do?
Eases the timeseries data management
▶ Convenient timeseries specific functions (hyperfunctions)
▶ Gap-filling and Interpolation
▶ Weighted averages
▶ . . .
▶ Partitioning (hypertables)
▶ Access less data (faster runtime)
▶ Compression
▶ Make data smaller (also faster runtime)
SFScon 2022 13/22 A. Dignös
Hyperfunctions/1
SFScon 2022 14/22 A. Dignös
Hyperfunctions/2
Produce a value every five minutes and interpolate missing ones
SELECT time_bucket_gapfill (’5␣minutes ’, time) AS five_min ,
avg(value) AS value , -- average from data
interpolate(avg(value )) -- interpolate average if missing
FROM sensor_signal
WHERE sensor_id = 3 AND time BETWEEN now () - INTERVAL ’20␣min ’
AND now ()
GROUP BY five_min
ORDER BY five_min;
five_min | value | interpolate
---------------------+-------+-------------
2022-11-11 15:40:00 | 16.2 | 16.2
2022-11-11 15:45:00 | | 16
2022-11-11 15:50:00 | 15.8 | 15.8
2022-11-11 15:55:00 | | 11.9
2022-11-11 16:00:00 | 8 | 8
SFScon 2022 15/22 A. Dignös
Hypertables/1
3
Picture taken from timescale.com
SFScon 2022 16/22 A. Dignös
Hypertables/2
Transform our table into a hypertable
SELECT create_hypertable (
’sensor_signal ’,
’time ’,
chunk_time_interval => INTERVAL ’2␣days ’,
partitioning_column => ’sensor_id ’,
number_partitions => 2,
if_not_exists => true ,
migrate_data => true
);
▶ Partition by range on time every two days
▶ Partition by hash on id using 2 partitions
SFScon 2022 17/22 A. Dignös
Hypertables/3
▶ Be careful with the partitioning
▶ Relevant partitions are merged using UNION ALL
▶ New data keeps on adding partitions
▶ Example: 100 sensors and 3 years of data
chunk time interval => ’INTERVAL 7 days’
number partitions => 50
Result: potentially 3 · 52 · 50 = 7800 tables!!
SFScon 2022 18/22 A. Dignös
Compression
▶ Compression aims at reducing the size of the data
▶ Done at a per chunk (partition) level
▶ Usually also improves query time
▶ Transparent to the user
▶ Done via a TimescaleDB function
SFScon 2022 19/22 A. Dignös
Take home messages
▶ Timescale handles timeseries data transparently
▶ For you it is just a relation
▶ SQL will still work as before
▶ Use hyperfunctions
▶ Handy and much faster than custom builds
▶ Keep on improving
▶ Use hypertables
▶ Limit the search space
▶ But be careful with how to partition
▶ Use compression
▶ Improves performance substantially
▶ Should be used on (old) read-only data
SFScon 2022 20/22 A. Dignös
What are we working on?
▶ Period temporal data (project: ISTeP4)
▶ Temporal range and overlap joins
▶ Temporal anomalies in healthcare information systems
▶ Temporal key/foreign constraints
▶ Temporal histograms for cardinality estimation
▶ Time series data (project: PREMISE5)
▶ Predictive maintenance for industrial equipment
▶ Data ingestion infrastructure
▶ Data storage infrastructure
▶ Feature extraction
4
https://dbs.inf.unibz.it/projects/istep/
5
https://dbs.inf.unibz.it/projects/premise/
SFScon 2022 21/22 A. Dignös
Thank you!
anton.dignoes@unibz.it
SFScon 2022 22/22 A. Dignös

Weitere ähnliche Inhalte

Ähnlich wie SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf

KSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.doc
KSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.docKSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.doc
KSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.docRizalAhmad66
 
Spark Streaming and IoT by Mike Freedman
Spark Streaming and IoT by Mike FreedmanSpark Streaming and IoT by Mike Freedman
Spark Streaming and IoT by Mike FreedmanSpark Summit
 
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...NETWAYS
 
Democratization of NOSQL Document-Database over Relational Database Comparati...
Democratization of NOSQL Document-Database over Relational Database Comparati...Democratization of NOSQL Document-Database over Relational Database Comparati...
Democratization of NOSQL Document-Database over Relational Database Comparati...IRJET Journal
 
Best Practices: How to Analyze IoT Sensor Data with InfluxDB
Best Practices: How to Analyze IoT Sensor Data with InfluxDBBest Practices: How to Analyze IoT Sensor Data with InfluxDB
Best Practices: How to Analyze IoT Sensor Data with InfluxDBInfluxData
 
Maximizing Data Lake ROI with Data Virtualization: A Technical Demonstration
Maximizing Data Lake ROI with Data Virtualization: A Technical DemonstrationMaximizing Data Lake ROI with Data Virtualization: A Technical Demonstration
Maximizing Data Lake ROI with Data Virtualization: A Technical DemonstrationDenodo
 
Cloud Cost Management and Apache Spark with Xuan Wang
Cloud Cost Management and Apache Spark with Xuan WangCloud Cost Management and Apache Spark with Xuan Wang
Cloud Cost Management and Apache Spark with Xuan WangDatabricks
 
Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...
Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...
Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...DataStax Academy
 
State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016GeoSolutions
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
Combinação de logs, métricas e rastreamentos para observabilidade unificada
Combinação de logs, métricas e rastreamentos para observabilidade unificadaCombinação de logs, métricas e rastreamentos para observabilidade unificada
Combinação de logs, métricas e rastreamentos para observabilidade unificadaElasticsearch
 
Cloud-based Stream Analytics VS InfuxDB Time-series analytics
Cloud-based Stream Analytics  VS InfuxDB Time-series analyticsCloud-based Stream Analytics  VS InfuxDB Time-series analytics
Cloud-based Stream Analytics VS InfuxDB Time-series analyticsLeonardoSalvucci1
 
Paris Datageeks meetup 05102016
Paris Datageeks meetup 05102016Paris Datageeks meetup 05102016
Paris Datageeks meetup 05102016Michel Caradec
 
Application Monitoring using Open Source: VictoriaMetrics - ClickHouse
Application Monitoring using Open Source: VictoriaMetrics - ClickHouseApplication Monitoring using Open Source: VictoriaMetrics - ClickHouse
Application Monitoring using Open Source: VictoriaMetrics - ClickHouseVictoriaMetrics
 
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Altinity Ltd
 
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...WSO2
 
Webinar: Cutting Time, Complexity and Cost from Data Science to Production
Webinar: Cutting Time, Complexity and Cost from Data Science to ProductionWebinar: Cutting Time, Complexity and Cost from Data Science to Production
Webinar: Cutting Time, Complexity and Cost from Data Science to Productioniguazio
 

Ähnlich wie SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf (20)

KSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.doc
KSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.docKSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.doc
KSK1014 COMPUTER SYSTEM HARDWARE INSTALLATION.doc
 
Spark Streaming and IoT by Mike Freedman
Spark Streaming and IoT by Mike FreedmanSpark Streaming and IoT by Mike Freedman
Spark Streaming and IoT by Mike Freedman
 
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
 
Democratization of NOSQL Document-Database over Relational Database Comparati...
Democratization of NOSQL Document-Database over Relational Database Comparati...Democratization of NOSQL Document-Database over Relational Database Comparati...
Democratization of NOSQL Document-Database over Relational Database Comparati...
 
Best Practices: How to Analyze IoT Sensor Data with InfluxDB
Best Practices: How to Analyze IoT Sensor Data with InfluxDBBest Practices: How to Analyze IoT Sensor Data with InfluxDB
Best Practices: How to Analyze IoT Sensor Data with InfluxDB
 
Maximizing Data Lake ROI with Data Virtualization: A Technical Demonstration
Maximizing Data Lake ROI with Data Virtualization: A Technical DemonstrationMaximizing Data Lake ROI with Data Virtualization: A Technical Demonstration
Maximizing Data Lake ROI with Data Virtualization: A Technical Demonstration
 
Cloud Cost Management and Apache Spark with Xuan Wang
Cloud Cost Management and Apache Spark with Xuan WangCloud Cost Management and Apache Spark with Xuan Wang
Cloud Cost Management and Apache Spark with Xuan Wang
 
Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...
Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...
Timeli: Believing Cassandra: Our Big-Data Journey To Enlightenment under the ...
 
State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
Combinação de logs, métricas e rastreamentos para observabilidade unificada
Combinação de logs, métricas e rastreamentos para observabilidade unificadaCombinação de logs, métricas e rastreamentos para observabilidade unificada
Combinação de logs, métricas e rastreamentos para observabilidade unificada
 
Cloud-based Stream Analytics VS InfuxDB Time-series analytics
Cloud-based Stream Analytics  VS InfuxDB Time-series analyticsCloud-based Stream Analytics  VS InfuxDB Time-series analytics
Cloud-based Stream Analytics VS InfuxDB Time-series analytics
 
Cloud, Fog, or Edge: Where and When to Compute?
Cloud, Fog, or Edge: Where and When to Compute?Cloud, Fog, or Edge: Where and When to Compute?
Cloud, Fog, or Edge: Where and When to Compute?
 
Paris Datageeks meetup 05102016
Paris Datageeks meetup 05102016Paris Datageeks meetup 05102016
Paris Datageeks meetup 05102016
 
Application Monitoring using Open Source: VictoriaMetrics - ClickHouse
Application Monitoring using Open Source: VictoriaMetrics - ClickHouseApplication Monitoring using Open Source: VictoriaMetrics - ClickHouse
Application Monitoring using Open Source: VictoriaMetrics - ClickHouse
 
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
 
CEAZA mega board: an open-source data logger for scientists
CEAZA mega board: an open-source data logger for scientistsCEAZA mega board: an open-source data logger for scientists
CEAZA mega board: an open-source data logger for scientists
 
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
 
Webinar: Cutting Time, Complexity and Cost from Data Science to Production
Webinar: Cutting Time, Complexity and Cost from Data Science to ProductionWebinar: Cutting Time, Complexity and Cost from Data Science to Production
Webinar: Cutting Time, Complexity and Cost from Data Science to Production
 

Mehr von South Tyrol Free Software Conference

SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...
SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...
SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...South Tyrol Free Software Conference
 
SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...
SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...
SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...South Tyrol Free Software Conference
 
SFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data Hub
SFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data HubSFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data Hub
SFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data HubSouth Tyrol Free Software Conference
 
SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...
SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...
SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...South Tyrol Free Software Conference
 
SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...
SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...
SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...South Tyrol Free Software Conference
 
SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...
SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...
SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...South Tyrol Free Software Conference
 
SFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelines
SFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelinesSFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelines
SFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelinesSouth Tyrol Free Software Conference
 
SFSCON23 - Charles H. Schulz - Why open digital infrastructure matters
SFSCON23 - Charles H. Schulz - Why open digital infrastructure mattersSFSCON23 - Charles H. Schulz - Why open digital infrastructure matters
SFSCON23 - Charles H. Schulz - Why open digital infrastructure mattersSouth Tyrol Free Software Conference
 
SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...
SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...
SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...South Tyrol Free Software Conference
 
SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...
SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...
SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...South Tyrol Free Software Conference
 
SFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free software
SFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free softwareSFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free software
SFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free softwareSouth Tyrol Free Software Conference
 
SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...
SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...
SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...South Tyrol Free Software Conference
 
SFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changer
SFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changerSFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changer
SFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changerSouth Tyrol Free Software Conference
 
SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...
SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...
SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...South Tyrol Free Software Conference
 
SFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation Internet
SFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation InternetSFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation Internet
SFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation InternetSouth Tyrol Free Software Conference
 
SFSCON23 - Davide Vernassa - Empowering Insights Unveiling the latest innova...
SFSCON23 - Davide Vernassa - Empowering Insights  Unveiling the latest innova...SFSCON23 - Davide Vernassa - Empowering Insights  Unveiling the latest innova...
SFSCON23 - Davide Vernassa - Empowering Insights Unveiling the latest innova...South Tyrol Free Software Conference
 

Mehr von South Tyrol Free Software Conference (20)

SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...
SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...
SFSCON23 - Rufai Omowunmi Balogun - SMODEX – a Python package for understandi...
 
SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...
SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...
SFSCON23 - Roberto Innocenti - From the design to reality is here the Communi...
 
SFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data Hub
SFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data HubSFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data Hub
SFSCON23 - Martin Rabanser - Real-time aeroplane tracking and the Open Data Hub
 
SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...
SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...
SFSCON23 - Marianna d'Atri Enrico Zanardo - How can Blockchain technologies i...
 
SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...
SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...
SFSCON23 - Lucas Lasota - The Future of Connectivity, Open Internet and Human...
 
SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...
SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...
SFSCON23 - Giovanni Giannotta - Intelligent Decision Support System for trace...
 
SFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelines
SFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelinesSFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelines
SFSCON23 - Elena Maines - Embracing CI/CD workflows for building ETL pipelines
 
SFSCON23 - Christian Busse - Free Software and Open Science
SFSCON23 - Christian Busse - Free Software and Open ScienceSFSCON23 - Christian Busse - Free Software and Open Science
SFSCON23 - Christian Busse - Free Software and Open Science
 
SFSCON23 - Charles H. Schulz - Why open digital infrastructure matters
SFSCON23 - Charles H. Schulz - Why open digital infrastructure mattersSFSCON23 - Charles H. Schulz - Why open digital infrastructure matters
SFSCON23 - Charles H. Schulz - Why open digital infrastructure matters
 
SFSCON23 - Andrea Vianello - Achieving FAIRness with EDP-portal
SFSCON23 - Andrea Vianello - Achieving FAIRness with EDP-portalSFSCON23 - Andrea Vianello - Achieving FAIRness with EDP-portal
SFSCON23 - Andrea Vianello - Achieving FAIRness with EDP-portal
 
SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...
SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...
SFSCON23 - Thomas Aichner - How IoT and AI are revolutionizing Mass Customiza...
 
SFSCON23 - Stefan Mutschlechner - Smart Werke Meran
SFSCON23 - Stefan Mutschlechner - Smart Werke MeranSFSCON23 - Stefan Mutschlechner - Smart Werke Meran
SFSCON23 - Stefan Mutschlechner - Smart Werke Meran
 
SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...
SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...
SFSCON23 - Mirko Boehm - European regulators cast their eyes on maturing OSS ...
 
SFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free software
SFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free softwareSFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free software
SFSCON23 - Marco Pavanelli - Monitoring the fleet of Sasa with free software
 
SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...
SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...
SFSCON23 - Marco Cortella - KNOWAGE and AICS for 2030 agenda SDG goals monito...
 
SFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changer
SFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changerSFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changer
SFSCON23 - Lina Ceballos - Interoperable Europe Act - A real game changer
 
SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...
SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...
SFSCON23 - Johannes Näder Linus Sehn - Let’s monitor implementation of Free S...
 
SFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation Internet
SFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation InternetSFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation Internet
SFSCON23 - Gabriel Ku Wei Bin - Why Do We Need A Next Generation Internet
 
SFSCON23 - Edoardo Scepi - The Brand-New Version of IGis Maps
SFSCON23 - Edoardo Scepi - The Brand-New Version of IGis MapsSFSCON23 - Edoardo Scepi - The Brand-New Version of IGis Maps
SFSCON23 - Edoardo Scepi - The Brand-New Version of IGis Maps
 
SFSCON23 - Davide Vernassa - Empowering Insights Unveiling the latest innova...
SFSCON23 - Davide Vernassa - Empowering Insights  Unveiling the latest innova...SFSCON23 - Davide Vernassa - Empowering Insights  Unveiling the latest innova...
SFSCON23 - Davide Vernassa - Empowering Insights Unveiling the latest innova...
 

Kürzlich hochgeladen

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf

  • 1. Managing Temporal Data in PostgreSQL Anton Dignös Free University of Bozen-Bolzano SFScon 2022 November 11, 2022 AUTONOME PROVINZ BOZEN SÜDTIROL PROVINCIA AUTONOMA DI BOLZANO ALTO ADIGE Research Südtirol/Alto Adige 2019 Project ISTeP CUP: I52F20000250003 EFRE 2014-2020 Project EFRE1164 PREMISE CUP: I59C20000340009
  • 2. Agenda What is temporal data? Period temporal data in Postgres Time series data in Postgres What are we working on? This talk will only provide a glimpse, if you are interested in more details, I am happy to talk to you during the conference! SFScon 2022 2/22 A. Dignös
  • 3. Temporal data Temporal data can be found in many application ▶ HR contracts ▶ Insurance policies ▶ Tourism data ▶ Medical domain ▶ Stock market data ▶ Industrial data SFScon 2022 3/22 A. Dignös
  • 4. What is temporal data? Data with a “timestamp” + The “timestamp” indicates the validity of the data Examples: ▶ A contract with a validity period ▶ A sensor reading with the measurement time ▶ An error event with the happening time SFScon 2022 4/22 A. Dignös
  • 5. Basic utilities for date/time in Postgres ▶ Postgres provides different date/time datatypes1 ▶ Many functions ▶ Operators (+, -) ▶ Calendar functions (EXTRACT, date trunc) ▶ Whoever worked with dates/timezones knows to appreciate these 1 https://www.postgresql.org/docs/current/datatype-datetime.html SFScon 2022 5/22 A. Dignös
  • 6. Topic of today Today it is about temporal data, not just storing dates or time ▶ Period temporal data ▶ Contracts ▶ Manufacturing periods ▶ Error states ▶ Time series data ▶ Sensor readings ▶ Stock market data ▶ Error events Let’s have a peek on what Postgres and it’s ecosystem has to offer! SFScon 2022 6/22 A. Dignös
  • 7. Highlights for period temporal data in Postgres ▶ Postgres provides range types2 for managing period data ▶ What are range types? ▶ Datatypes for periods ’[start, end)’ ▶ Can have different forms – ’[ , )’,’[ , ]’, ’( , ]’, ’( , )’ ▶ Available for different types, e.g., INT, NUMERIC, DATE ▶ Many predicates and functions ▶ Indices available (GiST, SP-GiST, btree gist) ▶ Very easy to use ▶ Avoid many programming mistakes 2 https://www.postgresql.org/docs/current/rangetypes.html SFScon 2022 7/22 A. Dignös
  • 8. An example Product prices that change over time CREATE TABLE prices( product INT , period DATERANGE , value FLOAT ); INSERT INTO prices VALUES (1, ’[2021 -08 -01 ,␣2022 -08 -01) ’, 25), (1, ’[2022 -08 -01 ,) ’, 30), (2, ’[2021 -08 -01 ,␣2022 -04 -01) ’, 10), (2, ’[2022 -04 -01 ,) ’, 20); product | period | value ---------+-------------------------+------- 1 | [2021-08-01,2022-08-01) | 25 1 | [2022-08-01,) | 30 2 | [2021-08-01,2022-04-01) | 10 2 | [2022-04-01,) | 20 SFScon 2022 8/22 A. Dignös
  • 9. Common queries ▶ What are the prices of products today? WHERE period @> CURRENT_DATE ▶ What were the prices of products on the 2021-10-30? WHERE period @> ’2021 -10 -30 ’ ▶ What were the previous prices of products? WHERE period << daterange(CURRENT_DATE , NULL , ’[)’) ▶ What were the prices of products between 2021-10-30 and 2022-10-30? WHERE period && DATERANGE(’2021 -10 -30 ’,’2022 -10 -30 ’, ’[]’) SFScon 2022 9/22 A. Dignös
  • 10. Uniqueness Constraints Ensure a product does not have two prices at the same time CREATE TABLE prices( product INT , period DATERANGE , value FLOAT , EXCLUDE USING GIST (product WITH =, period WITH &&)); product | period | value ---------+-------------------------+------- 1 | [2021-08-01,2022-08-01) | 25 1 | [2022-08-01,) | 30 2 | [2021-08-01,2022-04-01) | 10 2 | [2022-04-01,) | 20 INSERT INTO product_prices VALUES (1, ’[2022 -08 -04 ,) ’, 100); ERROR: conflicting key value violates exclusion constraint ... DETAIL: Key (product, period)=(1, [2022-08-04,)) conflicts ... SFScon 2022 10/22 A. Dignös
  • 11. Take home messages ▶ Range types is Postgres’ native period datatype ▶ Convenient representation of periods ▶ Many base datatypes are supported ▶ Support different period definitions if needed ▶ Many convenient predicates and functions ▶ Less error prone than custom builds ▶ Can be speed up using GiST indices ▶ Uniqueness constraints available ▶ Avoid inconsistencies at the source SFScon 2022 11/22 A. Dignös
  • 12. Highlights for time series data in Postgres ▶ TimescaleDB can be used to manage time series in Postgres ▶ What is TimescaleDB? ▶ TimescaleDB is a Postgres extension (based on UDFs) ▶ Runs on server side ▶ License (two versions of TimescaleDB with different support)3 ▶ TimescaleDB Apache 2 Edition (Apache 2.0 license) ▶ TimescaleDB Community Edition (Timescale License – TSL) ▶ See https://docs.timescale.com/timescaledb/latest/ timescaledb-edition-comparison ▶ Available for most platforms as a binary or compile form source 3 Thanks to Chris Mair from 1006.org for pointing this out during a previous talk! SFScon 2022 12/22 A. Dignös
  • 13. What does TimescaleDB do? Eases the timeseries data management ▶ Convenient timeseries specific functions (hyperfunctions) ▶ Gap-filling and Interpolation ▶ Weighted averages ▶ . . . ▶ Partitioning (hypertables) ▶ Access less data (faster runtime) ▶ Compression ▶ Make data smaller (also faster runtime) SFScon 2022 13/22 A. Dignös
  • 15. Hyperfunctions/2 Produce a value every five minutes and interpolate missing ones SELECT time_bucket_gapfill (’5␣minutes ’, time) AS five_min , avg(value) AS value , -- average from data interpolate(avg(value )) -- interpolate average if missing FROM sensor_signal WHERE sensor_id = 3 AND time BETWEEN now () - INTERVAL ’20␣min ’ AND now () GROUP BY five_min ORDER BY five_min; five_min | value | interpolate ---------------------+-------+------------- 2022-11-11 15:40:00 | 16.2 | 16.2 2022-11-11 15:45:00 | | 16 2022-11-11 15:50:00 | 15.8 | 15.8 2022-11-11 15:55:00 | | 11.9 2022-11-11 16:00:00 | 8 | 8 SFScon 2022 15/22 A. Dignös
  • 16. Hypertables/1 3 Picture taken from timescale.com SFScon 2022 16/22 A. Dignös
  • 17. Hypertables/2 Transform our table into a hypertable SELECT create_hypertable ( ’sensor_signal ’, ’time ’, chunk_time_interval => INTERVAL ’2␣days ’, partitioning_column => ’sensor_id ’, number_partitions => 2, if_not_exists => true , migrate_data => true ); ▶ Partition by range on time every two days ▶ Partition by hash on id using 2 partitions SFScon 2022 17/22 A. Dignös
  • 18. Hypertables/3 ▶ Be careful with the partitioning ▶ Relevant partitions are merged using UNION ALL ▶ New data keeps on adding partitions ▶ Example: 100 sensors and 3 years of data chunk time interval => ’INTERVAL 7 days’ number partitions => 50 Result: potentially 3 · 52 · 50 = 7800 tables!! SFScon 2022 18/22 A. Dignös
  • 19. Compression ▶ Compression aims at reducing the size of the data ▶ Done at a per chunk (partition) level ▶ Usually also improves query time ▶ Transparent to the user ▶ Done via a TimescaleDB function SFScon 2022 19/22 A. Dignös
  • 20. Take home messages ▶ Timescale handles timeseries data transparently ▶ For you it is just a relation ▶ SQL will still work as before ▶ Use hyperfunctions ▶ Handy and much faster than custom builds ▶ Keep on improving ▶ Use hypertables ▶ Limit the search space ▶ But be careful with how to partition ▶ Use compression ▶ Improves performance substantially ▶ Should be used on (old) read-only data SFScon 2022 20/22 A. Dignös
  • 21. What are we working on? ▶ Period temporal data (project: ISTeP4) ▶ Temporal range and overlap joins ▶ Temporal anomalies in healthcare information systems ▶ Temporal key/foreign constraints ▶ Temporal histograms for cardinality estimation ▶ Time series data (project: PREMISE5) ▶ Predictive maintenance for industrial equipment ▶ Data ingestion infrastructure ▶ Data storage infrastructure ▶ Feature extraction 4 https://dbs.inf.unibz.it/projects/istep/ 5 https://dbs.inf.unibz.it/projects/premise/ SFScon 2022 21/22 A. Dignös