Fireship · @fireship

TimescaleDB in 100 Seconds

Uploaded August 9, 2024 · Length 2:34

TimescaleDB in 100 Seconds

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.

  1. 0:00

    the time scale DB an open- Source Time

  2. 0:02

    series database built on top of

  3. 0:04

    postgress that can query time-based

  4. 0:06

    workloads exponentially faster imagine

  5. 0:09

    building an application that needs to

  6. 0:10

    collect terabytes of timestamp data

  7. 0:12

    points every day like a website

  8. 0:14

    analytics platform or an iot smart

  9. 0:16

    toilet a general purpose SQL database

  10. 0:18

    like MySQL or postgress is not ideal it

  11. 0:21

    doesn't ingest data fast enough and

  12. 0:23

    isn't optimized to scale queries of Time

  13. 0:25

    series data a time scale DB fixes this

  14. 0:28

    by storing data in hyper tabls which are

  15. 0:30

    abstract tables composed of many smaller

  16. 0:32

    postgress tables called chunks this can

  17. 0:34

    increase inest speeds up to 40% and make

  18. 0:37

    queries a staggering 350 times faster in

  19. 0:40

    addition time buckets can automatically

  20. 0:42

    aggregate data into set intervals while

  21. 0:44

    hyper functions allow you to analyze

  22. 0:46

    this data like a mad scientist they can

  23. 0:49

    compute time weighted averages for

  24. 0:50

    financial data and build Candlestick

  25. 0:52

    charts or aggregate the daily water

  26. 0:54

    consumption of your iot smart toilet

  27. 0:56

    best of all it does this while

  28. 0:57

    maintaining full SQL support before

  29. 0:59

    traditional relational workloads to get

  30. 1:01

    started you can run it locally and

  31. 1:03

    self-host it with Docker but the easiest

  32. 1:05

    option is to try it for free right now

  33. 1:07

    with time scale Cloud but first create a

  34. 1:09

    service for free to launch your database

  35. 1:11

    and get connection credentials then

  36. 1:13

    connect to it with your favorite client

  37. 1:14

    library or as I'm doing here make a

  38. 1:16

    connection in your IDE to write raw SQL

  39. 1:19

    code now I run a popular app where

  40. 1:21

    people can get matched up to horses and

  41. 1:22

    I want to query the total number of

  42. 1:24

    trips taken in a month I can make that

  43. 1:26

    query in plain postgress by selecting

  44. 1:28

    the count from the trips table then

  45. 1:29

    filter out records for a date range with

  46. 1:31

    a wear Clause the problem though is that

  47. 1:33

    it's extremely slow because I have over

  48. 1:35

    7 million records just on this one query

  49. 1:37

    we can start to see the power of time

  50. 1:38

    scale when we alter the code slightly to

  51. 1:40

    use a hypertable which cuts the

  52. 1:42

    execution time in half that's not all

  53. 1:44

    though we can also compress this

  54. 1:45

    hypertable to make the query even faster

  55. 1:47

    and reduce dis usage by up to 90% but

  56. 1:50

    now let's imagine we want to show a

  57. 1:52

    chart in the analytics dashboard that

  58. 1:54

    shows the highest amount paid for a ride

  59. 1:55

    each day A Time bucket query takes that

  60. 1:58

    original date range and aggregates data