Fireship · @fireship
TimescaleDB in 100 Seconds
Uploaded August 9, 2024 · Length 2:34
Summary
timescaledb explained: a fast time series database built on postgres for querying large datasets
- timescaledb
- postgres
- time series database
- sql database
- database performance
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
the time scale DB an open- Source Time
- 0:02
series database built on top of
- 0:04
postgress that can query time-based
- 0:06
workloads exponentially faster imagine
- 0:09
building an application that needs to
- 0:10
collect terabytes of timestamp data
- 0:12
points every day like a website
- 0:14
analytics platform or an iot smart
- 0:16
toilet a general purpose SQL database
- 0:18
like MySQL or postgress is not ideal it
- 0:21
doesn't ingest data fast enough and
- 0:23
isn't optimized to scale queries of Time
- 0:25
series data a time scale DB fixes this
- 0:28
by storing data in hyper tabls which are
- 0:30
abstract tables composed of many smaller
- 0:32
postgress tables called chunks this can
- 0:34
increase inest speeds up to 40% and make
- 0:37
queries a staggering 350 times faster in
- 0:40
addition time buckets can automatically
- 0:42
aggregate data into set intervals while
- 0:44
hyper functions allow you to analyze
- 0:46
this data like a mad scientist they can
- 0:49
compute time weighted averages for
- 0:50
financial data and build Candlestick
- 0:52
charts or aggregate the daily water
- 0:54
consumption of your iot smart toilet
- 0:56
best of all it does this while
- 0:57
maintaining full SQL support before
- 0:59
traditional relational workloads to get
- 1:01
started you can run it locally and
- 1:03
self-host it with Docker but the easiest
- 1:05
option is to try it for free right now
- 1:07
with time scale Cloud but first create a
- 1:09
service for free to launch your database
- 1:11
and get connection credentials then
- 1:13
connect to it with your favorite client
- 1:14
library or as I'm doing here make a
- 1:16
connection in your IDE to write raw SQL
- 1:19
code now I run a popular app where
- 1:21
people can get matched up to horses and
- 1:22
I want to query the total number of
- 1:24
trips taken in a month I can make that
- 1:26
query in plain postgress by selecting
- 1:28
the count from the trips table then
- 1:29
filter out records for a date range with
- 1:31
a wear Clause the problem though is that
- 1:33
it's extremely slow because I have over
- 1:35
7 million records just on this one query
- 1:37
we can start to see the power of time
- 1:38
scale when we alter the code slightly to
- 1:40
use a hypertable which cuts the
- 1:42
execution time in half that's not all
- 1:44
though we can also compress this
- 1:45
hypertable to make the query even faster
- 1:47
and reduce dis usage by up to 90% but
- 1:50
now let's imagine we want to show a
- 1:52
chart in the analytics dashboard that
- 1:54
shows the highest amount paid for a ride
- 1:55
each day A Time bucket query takes that
- 1:58
original date range and aggregates data


