Skip to content

The TimescaleDB Ruby Gem

Welcome to the TimescaleDB gem! To experiment with the code, start installing the gem:


You can install the gem locally:

gem install timescaledb

Or require it directly in the Gemfile of your project:

gem "timescaledb"


  • The model can use the acts_as_hypertable macro. Check more on models documentation.
  • The ActiveRecord migrations can use the create_table supporting the hypertable keyword. It's also enabling you to add retention and continuous aggregates policies
  • A standalone create_hypertable macro is also allowed in the migrations.
  • Testing also becomes easier as the schema dumper will automatically introduce the hypertables to all environments.
  • It also contains a scenic extension to work with scenic views as it's a wide adoption in the community.
  • The gem is also packed with a command line utility that makes it easier to navigate in your database with Pry and all your hypertables available in a Ruby style.


The all_in_one example shows:

  1. Create a hypertable with compression settings
  2. Insert data
  3. Run some queries
  4. Check chunk size per model
  5. Compress a chunk
  6. Check chunk status
  7. Decompress a chunk

The ranking example shows how to configure a Rails app and navigate all the features available.

Toolkit examples

There are also examples in the toolkit-demo folder that can help you to understand how to properly use the toolkit functions.

  • ohlc is a funtion that groups data by Open, High, Low, Close and make histogram availables to group the data, very useful for financial analysis.
  • While building the LTTB tutorial I created the lttb is a simple charting using the Largest Triangle Three Buckets and there. A zoomable version which allows to navigate in the data and zoom it keeping the same data resolution is also available.
  • A small example showing how to process volatility is also good to get familiar with the pipeline functions. A benchmark implementing the same in Ruby is also available to check how it compares to the SQL implementation.

Extra resources

If you need extra help, please join the fantastic timescale community or ask your question on StackOverflow using the #timescaledb tag.

If you want to go deeper in the library, the videos links to all live-coding sessions showed how @jonatasdp built the gem.


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.


The gem is available as open source under the MIT License.

Code of Conduct

Everyone interacting in the Timescale project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.