timescale / promscale_extension

[DEPRECATED] Tables, types and functions supporting Promscale
Other
37 stars 17 forks source link
deprecated

Warning

Promscale has been discontinued and is deprecated.

The code in this repository is no longer maintained.

Learn more.

Promscale Extension

From Promscale version 0.11.0, this Postgres extension is an integral part of Promscale. It is required to be installed. Check the release notes for more details.

The extension plays two important roles:

  1. It manages the SQL data schema and migrations that manipulate it.
  2. It encompasses code that runs within a database instance, both PL/pgSQL and native.

Motivation

It's fairly common for backend applications to manage their database schema via a migration system. Altering a table and adding an index are typical operations that come to mind. As Promscale grew in scope and complexity we found ourselves defining custom data types, aggregates and background jobs. Having the extension manage both the migration logic and various extensions helps to deal with situations when one depends on the other.

Yet, developer convenience is not the main reason this extension exists. It enables complex optimizations for both PromQL and SQL users. Let's have a look at two examples.

Custom aggregates like prom_rate, prom_delta and a few others are implemented in Rust and enable Promscale to push corresponding PromQL down to native code that is executed within PostgreSQL. The alternatives are either transferring all the data to the Promscale application and doing aggregation there, or a PL/pgSQL stored procedure. Both are substantially slower.

Support functions that transparently rewrite some queries to reduce the amount of computation required or take advantage of indices and tables specific to Promscale. For instance, the following query:

SELECT trace_id
    FROM ps_trace.span
    WHERE
            span_tags -> 'pwlen' = '25'::jsonb
        AND resource_tags -> 'service.name' = '"generator"';

will have an additional InitPlan stage that precomputes a set of matching tags, then uses a GIN index on a private _ps_trace.span table. While the naive version can only evaluate matching tags per row.

Requirements

To run the extension:

To compile the extension (see instructions below):

Installation

Development

To quickly setup a development environment, see DEVELOPMENT.md To understand more about how to write SQL migration files for this extension, consult this guide. To get a better understanding of our CI pipeline see this document.

Releasing

A full checklist of the steps necessary to release a new version of the extension is available in RELEASING.md.