brainlid

brainlid

Episode 129 of Thinking Elixir. Tracking, analyzing and visualizing time series data can add a lot of business value to a project! We met up with Dave Lucia to learn more about Timescale DB, a PostgreSQL extension that adds time series tools to our regular database. Dave also created a timescale hex package to make it easier to work with hypertables and hyperfunctions. We learn why Timescale DB makes sense over other options, how to get started with it, example use cases, helpful resources and more!

Showing Posts 1 to 6

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

We’ve been using TimescaleDB at CargoSense for a couple of years now, and it has worked really well for us. In particular, the compression feature gives us 96%+ compression rate which makes a huge difference. Concretely we have a ~terrabyte’s worth of data taking up 55 gigabytes and for our query patterns, we see negligible performance performance impact for queries on compressed chunks.

For us it’s a sweet spot on trade offs. We get to keep the simplicity of running “just” postgres, we get to keep all our transactional guarantees with other code, and we also get to store bunch of timeseries data.

The only “gotcha” is that, like all partitioned tables, you need to be storing “relevant time range” values around so that you can query the right range. Eg if you had a sensor and you wanted to query its temperature readings in a shipment, you’d want to do a query like

Repo.all(from r in Reading,
  where: r.sensor_id == ^sensor.id,
  where: r.recorded_at >= ^shipment.starts_at and r.recorded_at <= ^shipment.ends_at

The r.recorded_at >= ^shipment.starts_at and r.recorded_at <= ^shipment.ends_at bit is important, even if a sensor is never used in multiple shipments because you need to help the query planner know in which chunks to go looking for readings.

brainlid

brainlid OP

Hi @benwilson512!

I’m glad to hear you’ve had such a good experience with it as well. And thanks for the query tip. Very helpful!

thbar

thbar

Hello @benwilson512!

We’re considering using TimescaleDB for long term metrics.

How are you integrating it with Elixir? Are you using a library (e.g. GitHub - davydog187/timescale: TimescaleDB made easy with Ecto · GitHub) or something more direct?

Thanks!

Schultzer

Schultzer

You might not need timescale with Postgres today.

Designing high-performance time series data tables on Amazon RDS for PostgreSQL | AWS Database Blog

dimitarvp

dimitarvp

This is not specific to RDS, correct? Seems like it refers to partitioning tables in a vanilla Postgres.

Schultzer

Schultzer

Yes, it’s Postgres in general!

— All posts loaded —

Where Next? Top

Trending in Podcasts Top

PJUllrich
Praia Labs has the numbers on Phoenix version and Bandit adoption, Sobelow 0.15 is out, and there’s a new book, Elixir for Finance. We al...
New
PJUllrich
Peter announces Pushin.eu, a GitHub competitor hosted in the EU, written in Elixir. Other topics include Phoenix ships security patches s...
New
ancatrusca
Part one of two with the WhatsApp developer experience team. This episode covers scale and operations; part two covers tooling and types....
New
ancatrusca
AtomVM supports GenServer, maps, JSON, Erlang distribution, and via Popcorn - Phoenix LiveView on a microcontroller. No OS, a few hundred...
New
ancatrusca
Part two of two. Part one covered scale and operations; this one covers the tooling that keeps a large codebase navigable. The practical...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews