Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@perrygeo
Last active January 9, 2019 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perrygeo/9f3419e39be014a3d3a6d56c7351bcf1 to your computer and use it in GitHub Desktop.
Save perrygeo/9f3419e39be014a3d3a6d56c7351bcf1 to your computer and use it in GitHub Desktop.

Installing pgextwlist

# Dockerfile
ENV PGEXTWLIST_VERSION 1.7
RUN wget -q -O pgextwlist-${PGEXTWLIST_VERSION}.tar.gz https://github.com/dimitri/pgextwlist/archive/v${PGEXTWLIST_VERSION}.tar.gz
RUN tar -xzf pgextwlist-${PGEXTWLIST_VERSION}.tar.gz && \
    cd pgextwlist-${PGEXTWLIST_VERSION} && \
    make -j${CPUS} && make install && \
    export pkg=$(pg_config --pkglibdir) && mkdir $pkg/plugins && cp $pkg/pgextwlist.so $pkg/plugins

# postgresql.conf
local_preload_libraries = 'pgextwlist'
extwlist.extensions = 'postgis,timescaledb'

Create an unprivledged user on a fresh $PGDATA

postgres=# create role test with login encrypted password 'test';
CREATE ROLE
postgres=# create database test with owner test;
CREATE DATABASE

PG 10.6, Timescale 1.0.0

psql (11.1, server 10.6)

test=> create extension timescaledb;
...
Running version 1.0.0
test=> \dx
                                      List of installed extensions
    Name     | Version |   Schema   |                            Description
-------------+---------+------------+-------------------------------------------------------------------
 plpgsql     | 1.0     | pg_catalog | PL/pgSQL procedural language
 timescaledb | 1.0.0   | public     | Enables scalable inserts and complex queries for time-series data

test=> create table events (time timestamptz, value numeric);
CREATE TABLE
test=> select create_hypertable('events', 'time');
NOTICE:  adding not-null constraint to column "time"
DETAIL:  Time dimensions cannot have NULL values
  create_hypertable
---------------------
 (1,public,events,t)
(1 row)

test=> insert into events values (now(), 10);
INSERT 0 1
test=> insert into events values (now(), 20);
INSERT 0 1
test=> insert into events values (now(), 30);
INSERT 0 1

PG 10.6 Timescale 1.1.1

test=> \dx
                                      List of installed extensions
    Name     | Version |   Schema   |                            Description
-------------+---------+------------+-------------------------------------------------------------------
 plpgsql     | 1.0     | pg_catalog | PL/pgSQL procedural language
 timescaledb | 1.0.0   | public     | Enables scalable inserts and complex queries for time-series data
 
test=> ALTER EXTENSION timescaledb UPDATE;
ALTER EXTENSION

test=> \dx
                                      List of installed extensions
    Name     | Version |   Schema   |                            Description
-------------+---------+------------+-------------------------------------------------------------------
 plpgsql     | 1.0     | pg_catalog | PL/pgSQL procedural language
 timescaledb | 1.1.1   | public     | Enables scalable inserts and complex queries for time-series data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment