Code Monkey home page Code Monkey logo

timescale / timescaledb Goto Github PK

View Code? Open in Web Editor NEW
16.5K 308.0 835.0 39.54 MB

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.

Home Page: https://www.timescale.com/

License: Other

Shell 1.31% PLpgSQL 25.41% C 67.73% Emacs Lisp 0.02% CMake 2.13% Batchfile 0.01% Python 1.22% Ruby 1.62% Perl 0.39% SmPL 0.16%
time-series-database postgresql time-series sql postgres tsdb iot financial-analysis analytics timescaledb

timescaledb's Introduction

Linux/macOS Linux i386 Windows Coverity Code Coverage OpenSSF
Build Status Linux/macOS Build Status Linux i386 Windows build status Coverity Scan Build Status Code Coverage OpenSSF Best Practices

TimescaleDB

TimescaleDB is an open-source database designed to make SQL scalable for time-series data. It is engineered up from PostgreSQL and packaged as a PostgreSQL extension, providing automatic partitioning across time and space (partitioning key), as well as full SQL support.

If you prefer not to install or administer your instance of TimescaleDB, try Timescale, our fully managed cloud offering (pay-as-you-go, with a free trial to start).

To determine which option is best for you, see Timescale Products for more information about our Apache-2 version, TimescaleDB Community (self-hosted), and Timescale Cloud (hosted), including: feature comparisons, FAQ, documentation, and support.

Below is an introduction to TimescaleDB. For more information, please check out these other resources:

For reference and clarity, all code files in this repository reference licensing in their header (either the Apache-2-open-source license or Timescale License (TSL) ). Apache-2 licensed binaries can be built by passing -DAPACHE_ONLY=1 to bootstrap.

Contributors welcome.

(To build TimescaleDB from source, see instructions in Building from source.)

Using TimescaleDB

TimescaleDB scales PostgreSQL for time-series data via automatic partitioning across time and space (partitioning key), yet retains the standard PostgreSQL interface.

In other words, TimescaleDB exposes what look like regular tables, but are actually only an abstraction (or a virtual view) of many individual tables comprising the actual data. This single-table view, which we call a hypertable, is comprised of many chunks, which are created by partitioning the hypertable's data in either one or two dimensions: by a time interval, and by an (optional) "partition key" such as device id, location, user id, etc. (Architecture discussion)

Virtually all user interactions with TimescaleDB are with hypertables. Creating tables and indexes, altering tables, inserting data, selecting data, etc., can (and should) all be executed on the hypertable.

From the perspective of both use and management, TimescaleDB just looks and feels like PostgreSQL, and can be managed and queried as such.

Before you start

PostgreSQL's out-of-the-box settings are typically too conservative for modern servers and TimescaleDB. You should make sure your postgresql.conf settings are tuned, either by using timescaledb-tune or doing it manually.

Creating a hypertable

-- Do not forget to create timescaledb extension
CREATE EXTENSION timescaledb;

-- We start by creating a regular SQL table
CREATE TABLE conditions (
  time        TIMESTAMPTZ       NOT NULL,
  location    TEXT              NOT NULL,
  temperature DOUBLE PRECISION  NULL,
  humidity    DOUBLE PRECISION  NULL
);

-- Then we convert it into a hypertable that is partitioned by time
SELECT create_hypertable('conditions', 'time');

Inserting and querying data

Inserting data into the hypertable is done via normal SQL commands:

INSERT INTO conditions(time, location, temperature, humidity)
  VALUES (NOW(), 'office', 70.0, 50.0);

SELECT * FROM conditions ORDER BY time DESC LIMIT 100;

SELECT time_bucket('15 minutes', time) AS fifteen_min,
    location, COUNT(*),
    MAX(temperature) AS max_temp,
    MAX(humidity) AS max_hum
  FROM conditions
  WHERE time > NOW() - interval '3 hours'
  GROUP BY fifteen_min, location
  ORDER BY fifteen_min DESC, max_temp DESC;

In addition, TimescaleDB includes additional functions for time-series analysis that are not present in vanilla PostgreSQL. (For example, the time_bucket function above.)

Installation

TimescaleDB is available pre-packaged for several platforms (Linux, Docker, MacOS, Windows). More information can be found in our documentation.

To build from source, see instructions here.

Timescale, a fully managed TimescaleDB in the cloud, is available via a free trial. Create a PostgreSQL database in the cloud with TimescaleDB pre-installed so you can power your application with TimescaleDB without the management overhead.

Resources

Architecture documents

Useful tools

  • timescaledb-tune: Helps set your PostgreSQL configuration settings based on your system's resources.
  • timescaledb-parallel-copy: Parallelize your initial bulk loading by using PostgreSQL's COPY across multiple workers.

Additional documentation

Community & help

Releases & updates

Contributing

timescaledb's People

Contributors

afiskon avatar akulkarni avatar akuzm avatar amytai avatar antekresic avatar cevian avatar davidkohn88 avatar did-g avatar erimatnor avatar fabriziomello avatar gayyappan avatar jchampio avatar jlockerman avatar jnidzwetzki avatar k-rus avatar kgyrtkirk avatar konskov avatar lkshminarayanan avatar mfreed avatar mfundul avatar mkindahl avatar ngalstyan4 avatar nikkhils avatar noctarius avatar olofr avatar pmwkaa avatar rafiasabih avatar robatticus avatar sb230132 avatar svenklemm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

timescaledb's Issues

Error when using sample data

OS: MacOS Sierra
Install method: docker, tag: latest (should be 0.0.7-beta)

I tried with the weather_small, weather_big, devices_small and got no errors. But there is no data in conditions table, has some data in locations table.

guidance on partitioning, chunk time interval, parallelism

Can you provide some guidance on the use of partitions and chunk_time_interval in terms of implications for layout and performance? There was no documentation that I could find on the chunk_time_interval. Found it in one of the sample sets provided.

Also are Postgres / your extensions able to run parallel scans across chunks (if the query is across chunks or requires a join with a different time series table)? Have recent versions of Postgres carried over some of the capabilities of green plum (which is now open sourced)?

I am testing the database on data where have 1 sample (with 110 measures) per second 24x7. Given the large # of samples and that most queries I would do would be within a given day historically it seemed to make sense to chunk on the day. I also have a categorical variable that divides the data set into 10 distinct sets. Hence I initially created the hyper table with:

SELECT create_hypertable('measures', 'stamp', 'instrument', 10, chunk_time_interval => 86400000000); 

Based on a comment in one of the example sets have been led to believe that the chunk_time_interval is expressed in microseconds.

I also created another table, which would be joined with this for specific queries with the same attributes. The resulting performance of these tables (querying within 1 historical day of data) was very poor. I had noticed that the performance using:

SELECT create_hypertable('measures', 'stamp', 'instrument', 2); 

with default chunk size and 2 partitions was an order or two of magnitude faster. I don't know enough about the data structures as to posit why there is such a significant performance difference. One table contained 300 million rows (on 2 x 7 years of data) and the other 20 million rows (on 1 x 1 year of data). Ultimately both tables would have 10 (instruments) x 7 (years) or possibly more instruments in the future.

Finally I should mention that I was testing this on an OS X 10.12.4 Mac with reasonably fast CPU (a higher end core i7), 32GB of memory with 4G dedicated to postgres, single disk for data, no stripping. Eventually would move to a linux box with a stripped disk array and with higher memory allocation.

make on Windows fails

C:\Program Files\PostgreSQL\timescaledb-master>"C:\Program Files (x86)\GnuWin32\bin\make.exe"
process_begin: CreateProcess(NULL, pg_config --pgxs, ...) failed.
'cat' is not recognized as an internal or external command,
operable program or batch file.
'cat' is not recognized as an internal or external command,
operable program or batch file.
process_begin: CreateProcess(NULL, cat sql/load_order.txt, ...) failed.
'cat' is not recognized as an internal or external command,
operable program or batch file.
'cat' is not recognized as an internal or external command,
operable program or batch file.
make: Nothing to be done for `all'.

Docker documentation

Hey guys,

just thought of letting you know about your Docker instructions.

The first step for me was to pull the Docker image (https://github.com/timescale/timescaledb/#option-2---docker-hub). There is no information on how to run the docker image and what ports need to be open, and environmental parameters provided. I think the Readme should be updated.

Knowing Postgres, I opened 5432 port, and continued with your “getting started” installation guide:

• Setting up an empty database
• Creating a hypertable
• Creating an index
• Inserting data
• Querying data

All done with the psql tool. When I closed the psql session and reconnected again, the data was not there, and inserts were failing on missing “dblink” extension. I recommend updating the documentation here, either instructing people to "CREATE EXTENSION IF NOT EXISTS dblink CASCADE;” or having the docker image already instantiated with the necessary extensions.

Later I found the docker-run.sh script (https://github.com/timescale/timescaledb/blob/master/scripts/docker-run.sh) which helps tremendously in setting up the container. It survives closing the psql connection, as well as Docker container restarts (as it mounts the volume). I would highly recommend referencing to this script in your Readme and Getting Started documentation.

I hope this feedback helps a bit.

Bug granting permissions

Reported on the forum

Having some trouble when I grant insert on a table to a user other than the superuser that created the table, getting errors when I try to insert into the table. No problem if I do the inserts as the superuser who created the table etc. error is must be owner of relation _hyper_1_1_0_partition.

\COPY returning incorrect count

When copying in data from the tutorial, the result of the COPY is incorrect, showing ~4M less rows than there should be:

$ psql -d nyc_data -c '\COPY rides FROM nyc_data_rides.csv CSV;'
COPY 6333482

$ wc -l nyc_data_rides.csv
 10906858 nyc_data_rides.csv

$ psql -d nyc_data -c 'SELECT COUNT(*) FROM rides;'
  count
----------
 10906858
(1 row)

Hypertable ID serial increments although no table created

If create_hypertable() is run on an existing hypertable, the hypertable serial ID is still incremented. Although not strictly a bug, it is something we might want to avoid in order to not eat a lot of IDs. For instance, one could first check for an existing hypertable before incrementing the ID.

Platform support?

What are the supported platforms for timescaledb? I've tried compiling on MacOS and FreeBSD, without success.

Build fails on older OS (e.g., CentOS 6.8), older versions of gcc

Hi,
gcc version:4.4.7

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -fpic -DINCLUDE_PACKAGE_SUPPORT=0 -MMD -I. -I./ -I/usr/local/postgresql-9.6.2/include/server -I/usr/local/postgresql-9.6.2/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/metadata_queries.o src/metadata_queries.c
In file included from src/metadata_queries.c:14:
src/chunk.h:23: error: redefinition of typedef ‘Chunk’
src/metadata_queries.h:6: note: previous declaration of ‘Chunk’ was here
make: *** [src/metadata_queries.o] Error 1

Work with Django / tables with auto ID?

Hi there.

I'm attempting to create a hypertable with a table generated by Django but when I try to call the create_hypertable function I get an error:

postgres=# SELECT create_hypertable('example', 'time');
ERROR:  Cannot create a unique index without the time column
CONTEXT:  PL/pgSQL function _timescaledb_internal.get_general_index_definition(regclass,regclass,_timescaledb_catalog.hypertable) line 27 at RAISE
SQL statement "SELECT 1
    FROM pg_index,
    LATERAL _timescaledb_meta_api.add_index(
        hypertable_row.id,
        hypertable_row.schema_name,
        (SELECT relname FROM pg_class WHERE oid = indexrelid::regclass),
        _timescaledb_internal.get_general_index_definition(indexrelid, indrelid, hypertable_row)
    )
    WHERE indrelid = main_table"
PL/pgSQL function create_hypertable(regclass,name,name,integer,smallint,name,name,_timescaledb_catalog.chunk_placement_type,bigint,boolean,boolean) line 97 at PERFORM

I think it's something to do with the auto PK that Django tries to create.
It may well be the correct approach for me to separate out my timescaledb database and my Django managed ones, but I thought it was worth posting here first incase there was some obvious way round this or if you could let me know what specifically it doesn't like about the Django table.

If it's of any use I've created a small example Django project and pasted below a pg_dump to show what Django's created tables look like.

CREATE TABLE example (
    id integer NOT NULL,
    "time" timestamp with time zone NOT NULL
);


CREATE SEQUENCE example_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE example_id_seq OWNED BY example.id;
ALTER TABLE ONLY example ALTER COLUMN id SET DEFAULT nextval('example_id_seq'::regclass);
SELECT pg_catalog.setval('example_id_seq', 1, false);
ALTER TABLE ONLY example
    ADD CONSTRAINT example_pkey PRIMARY KEY (id);

Thanks very much for any assistance you can give me on this. Please let me know if I can add anything else to help.

undefined dblink_disconnect

Using today's head :

tutotsdb=# select setup_db();
ERREUR: n'a pas pu charger la bibliothèque « /usr/lib/postgresql/9.6/lib/timescaledb.so » : /usr/lib/postgresql/9.6/lib/timescaledb.so: undefined symbol: dblink_disconnect

(ERROR: cannot load library /usr/lib/...)

UPSERTs not working correctly

My system often inserts records that are duplicated (data with the same timestamp and same value in partitioning column). This leads to duplication in data (waste storage and require data cleaning after queries)

My database setup:

CREATE TABLE conditions (
  time        TIMESTAMPTZ       NOT NULL,
  location    TEXT              NOT NULL,
  temperature DOUBLE PRECISION  NULL,
  humidity    DOUBLE PRECISION  NULL
);
SELECT create_hypertable('conditions', 'time', 'location', 2);

When I insert 2 rows with same values:

INSERT INTO conditions(location, time, temperature, humidity)
  VALUES ('office', '2017-06-25 03:34:16+00', 70.0, 50.0);
INSERT INTO conditions(location, time, temperature, humidity)
  VALUES ('office', '2017-06-25 03:34:16+00', 70.0, 50.0);

=> The conditions table will have 2 records with exactly same data.

Is there any way to make timescaledb silently ignore the second insert? If not, can you please suggest me an efficient way to remove duplicated rows regularly?

Many thanks!

Error in example queries on the home page?

Hi,

I'm trying out timescaledb. I was trying out some queries similar to those on the home page, such as

SELECT date_trunc(time, '15 min') AS 15min, COUNT(device_id)
FROM logs
WHERE cpu_level > 0.9 AND free_mem < 1024
  AND time > now() - interval '24 hours'
GROUP BY 15min
ORDER BY COUNT(device_id) DESC LIMIT 25;

However, this gives an error on the date_trunc function: No function matches the given name and argument types. You might need to add explicit type casts.

Indeed, I cannot find a usage like the one above in the postgres docs. Am I missing something or are the examples wrong?

make error,CentOS 6.5 X64,(PostgreSQL) 9.6.3(rpm install)

1.CentOS 6.5 X64,
2.postgresql96:
[root@localhost soft]# rpm -qa|grep postgres
postgresql96-9.6.3-1PGDG.rhel6.x86_64
postgresql96-contrib-9.6.3-1PGDG.rhel6.x86_64
postgresql96-devel-9.6.3-1PGDG.rhel6.x86_64
postgresql96-libs-9.6.3-1PGDG.rhel6.x86_64
postgresql96-server-9.6.3-1PGDG.rhel6.x86_64
[root@localhost soft]#
-bash-4.1$ psql --version
psql (PostgreSQL) 9.6.3

3.make error
-bash-4.1$ cd timescaledb-master
-bash-4.1$ make
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic -DINCLUDE_PACKAGE_SUPPORT=0 -MMD -I. -I./ -I/usr/pgsql-9.6/include/server -I/usr/pgsql-9.6/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/init.o src/init.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic -DINCLUDE_PACKAGE_SUPPORT=0 -MMD -I. -I./ -I/usr/pgsql-9.6/include/server -I/usr/pgsql-9.6/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/extension.o src/extension.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic -DINCLUDE_PACKAGE_SUPPORT=0 -MMD -I. -I./ -I/usr/pgsql-9.6/include/server -I/usr/pgsql-9.6/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/utils.o src/utils.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic -DINCLUDE_PACKAGE_SUPPORT=0 -MMD -I. -I./ -I/usr/pgsql-9.6/include/server -I/usr/pgsql-9.6/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/catalog.o src/catalog.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic -DINCLUDE_PACKAGE_SUPPORT=0 -MMD -I. -I./ -I/usr/pgsql-9.6/include/server -I/usr/pgsql-9.6/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/metadata_queries.o src/metadata_queries.c
In file included from src/metadata_queries.c:14:
src/chunk.h:23: error: redefinition of typedef ‘Chunk’
src/metadata_queries.h:6: note: previous declaration of ‘Chunk’ was here
make: *** [src/metadata_queries.o] Error 1
-bash-4.1$

Missing docs: how to scale horizontally

There seems to be many mentions of scaling horizontally with no clear description on how to make a system do that.

We need some docs on how this is done.

pg_dump does not work for single tables

I am facing an issue with the pg_dump command. I dump the data of my tables with the command:

pg_dump -a -U user -d database-t table> /my/path/table.bak

It works perfectly fine with standard tables but not with hypertable.
Is it possible to dump hypertables that way or do we have to use the COPY FROM in the doc. We have a specific usecase where we need to use INSERT INTO statements, too much complicated to explain in few lines.

`create_hypertable` duplicates index when creating default indexes

Running:

CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
CREATE TABLE cpu (time timestamptz, tags_id integer, hostname TEXT,usage_user DOUBLE PRECISION,usage_system DOUBLE PRECISION,usage_idle DOUBLE PRECISION,usage_nice DOUBLE PRECISION,usage_iowait DOUBLE PRECISION,usage_irq DOUBLE PRECISION,usage_softirq DOUBLE PRECISION,usage_steal DOUBLE PRECISION,usage_guest DOUBLE PRECISION,usage_guest_nice DOUBLE PRECISION);
CREATE INDEX ON cpu(tags_id, "time" DESC);
CREATE INDEX ON cpu (usage_user,time DESC);
SELECT create_hypertable('cpu'::regclass, 'time'::name, partitioning_column => 'tags_id'::name, number_partitions => 1::smallint, chunk_time_interval => 28800000000);

Results in two indexes on (tags_id, "time" DESC) (creating default indexes should not re-create this one).

Insert always reports 0 rows inserted

Reproduce:

CREATE TABLE tt(c timestamp with time zone);
SELECT create_hypertable('tt', 'c');
INSERT INTO tt VALUES('2016-11-15 17:30:00+05:30');
INSERT 0 0

Result should be
INSERT 0 1

Backup and Restore does not working

This is the error log when I tried to restore from the backup of my timescaledb:

postgres=# CREATE DATABASE coin;
CREATE DATABASE
postgres=# \c coin
You are now connected to database "coin" as user "postgres".
coin=# CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
CREATE EXTENSION
coin=# ALTER DATABASE coin  SET timescaledb.restoring='on';
ALTER DATABASE
coin=# \! pg_restore -d coin -U postgres coin.bak
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 204; 1259 17702 TABLE _hyper_4_103_chunk postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  function get_partition_for_key(text, integer) does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
    Command was: CREATE TABLE _hyper_4_103_chunk (
    CONSTRAINT partition CHECK (((get_partition_for_key(symbol, 32768) >= '0'::smallint) A...
pg_restore: [archiver (db)] could not execute query: ERROR:  relation "_hyper_4_103_chunk" does not exist
    Command was: ALTER TABLE _hyper_4_103_chunk OWNER TO postgres;


pg_restore: [archiver (db)] Error from TOC entry 205; 1259 17712 TABLE _hyper_4_104_chunk postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  function get_partition_for_key(text, integer) does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
    Command was: CREATE TABLE _hyper_4_104_chunk (
    CONSTRAINT partition CHECK (((get_partition_for_key(symbol, 32768) >= '0'::smallint) A...
pg_restore: [archiver (db)] could not execute query: ERROR:  relation "_hyper_4_104_chunk" does not exist
    Command was: ALTER TABLE _hyper_4_104_chunk OWNER TO postgres;

....
(many many more similar lines)

My first attempt I didn't enter CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE; but the log was exactly same as above.

Reconsider copies in planner.c

Internal code review/cleanup for performance: some node copies in planner.c may be unnecessary. Especially in create_partition_func_equals_const.

create_hypertable fails with unique index

Environment: running latest Docker image (0.0.9-beta) on Mac.

Running the SQL below causes an error on hypertable creation.
Creating a non-UNIQUE index works.
Using a PRIMARY KEY(ID) also fails.

DROP TABLE IF EXISTS number_facts ;
CREATE TABLE IF NOT EXISTS number_facts (
id BIGINT NOT NULL,
ts TIMESTAMP WITHOUT TIME ZONE,
value DOUBLE PRECISION NOT NULL
);
CREATE UNIQUE INDEX number_facts_u ON number_facts (id, ts) ;
SELECT create_hypertable('number_facts', 'ts', 'id', 2);

ERROR: Cannot process index with definition (no index name match) CREATE UNIQUE INDEX number_facts_u ON /TABLE_NAME/ USING btree (id, ts)
Where: PL/pgSQL function _timescaledb_internal.get_general_index_definition(regclass,regclass) line 28 at RAISE
SQL statement "SELECT 1
FROM pg_index,
LATERAL _timescaledb_meta_api.add_index(
hypertable_row.id,
hypertable_row.schema_name,
(SELECT relname FROM pg_class WHERE oid = indexrelid::regclass),
_timescaledb_internal.get_general_index_definition(indexrelid, indrelid)
)
WHERE indrelid = main_table"
PL/pgSQL function create_hypertable(regclass,name,name,integer,smallint,name,name,_timescaledb_catalog.chunk_placement_type,bigint) line 93 at PERFORM

Error when using sample data

OS: MacOS Sierra
Install method: homebrew

I was trying to use the sample data. I followed the setup instructions on http://docs-new.timescaledb.com/other-sample-datasets for the device_small dataset and had a problem with the command

psql -U postgres -d devices_small -h localhost < devices_small.bak

because I did not have a postgres superuser.

I created a postgres user, did a DROP DATABASE devices_small and tried again. Most of it went fine, but there was one error.

ERROR:  function _timescaledb_internal.on_modify_main_table() does not exist

and there doesn't appear to be any data in the database readings table, but there is data in the device_info table.

Update: I tried with the weather_small dataset and got the same error and again, no data in the conditions table, but the locations table has data

Plain-text password

In https://github.com/timescale/timescaledb/blob/master/sql/common/tables.sql there is a comment on the _timescaledb_catalog.cluster_user table.

CREATE TABLE IF NOT EXISTS _timescaledb_catalog.cluster_user (
    username TEXT NOT NULL PRIMARY KEY,
    password TEXT NULL --not any more of a security hole than usual since stored in  pg_user_mapping anyway
);

That comment is only partially accurate. The pg_catalog.pg_user_mapping table is viewable only by super users, whereas the cluster_user table appears to be viewable by non-superusers.
Are there plans to restrict access to that table, or more specifically, to the password column?

Use PG's own hash function instead of murmur3?

I did some code for a PG extension, and I needed a good and fast hash function; so I included murmur3 source files in the extension to get that good hash function. Later I realized that all the hash* functions accessible via #include "access/hash.h" were perfectly good hash functions for my needs, and I didn't have to include all that murmur3 source code in the extension. What's more, the PG hash functions already deal with CPU-architecture differences.

Do you have a special reason that requires murmur3 to be your hash function to create partition keys? The PG hash functions are based on Bob Jenkins's hash function (called lookup3 I think).

https://doxygen.postgresql.org/hashfunc_8c_source.html#l00177

If these hash functions are appropriate for your needs, you could use hashvarlena to get the int4 hash, then do the modulo arithmetic.

timeseries functions

I've been testing timescaledb on a few hundred million rows of data and happy with performance so far. One area where the feature set is lacking is with some basic functions often present on timeseries and/or analytic databases:

  1. median
  2. histogram
  3. percentile
  4. first / last
  5. cumsum

While there are (more complex) analogs for cumsum and first/last in Postgres, would be useful to have these available as efficient operations on a group, as applicable.

Aside from Spark and a couple of other "big data" platforms, was previously using Netezza which has a fairly large library of analytical functions.

SELECT failed with additional partitioning on integer column

SELECT failed if condition contains filter over integer column, wich was used as additional partitioning column.

CREATE TABLE history (
  timestamp TIMESTAMPTZ,
  object_id int,
  value int
);
SELECT create_hypertable('history', 'timestamp', 'object_id', 10);
SELECT * FROM history WHERE object_id = 1;

resulting:

ERROR:  function _timescaledb_catalog.get_partition_for_key(integer, integer) does not exist

Version 0.0.11-beta from dockerhub

Docker compose

Hey guys,

I am trying to bring up TimescaleDB via Docker Compose (as opposed to Docker run) and it seems to me that the extension is not being loaded.

Dockerfile

FROM timescale/timescaledb

ENV PGDATA=/var/lib/postgresql/data/timescaledb
VOLUME /var/lib/postgresql
EXPOSE 5432

ADD initialize.sh /docker-entrypoint-initdb.d/init-user-db.sh

initialize.sh

#!/bin/bash

psql --username "$POSTGRES_USER" <<EOF
CREATE DATABASE my_db WITH OWNER $POSTGRES_USER;
GRANT ALL PRIVILEGES ON DATABASE my_db TO $POSTGRES_USER;

\c my_db
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

CREATE TABLE IF NOT EXISTS  my_table (
  time      TIMESTAMP         NOT NULL,
  metric    TEXT              NOT NULL,
  usage     DOUBLE PRECISION  NOT NULL
);
SELECT create_hypertable('my_table', 'time');
CREATE INDEX IF NOT EXISTS usage_metric ON my_table (metric, time DESC);
EOF

Compose.yml

version: '3'

services:
  timescale:
    image: my_timescale
    command: postgres -c shared_preload_libraries=timescaledb
    ports:
      - 5432:5432
    environment:
      - POSTGRES_USER=my_user
      - POSTGRES_PASSWORD=my_password
    volumes:
      - ./timescale:/var/lib/postgresql

As you can see I am trying to load timescaledb extension via command: postgres -c shared_preload_libraries=timescaledb but it looks like nothing is happening. This is what I get as an output:

NOTICE:  installing required extension "postgres_fdw"
ERROR:  The timescaledb library is not preloaded
HINT:  Please preload the timescaledb library via shared_preload_libraries.

  This can be done by editing the config file at: /var/lib/postgresql/data/timescaledb/postgresql.conf
  and adding 'timescaledb' to the list in the shared_preload_libraries config.

    # Modify postgresql.conf:
      shared_preload_libraries = 'timescaledb'

  Another way to do this, if not preloading other libraries, is with the command:
  echo "shared_preload_libraries = 'timescaledb'" >> /var/lib/postgresql/data/timescaledb/postgresql.conf 

  (Will require a database restart.)

  If you REALLY know what you are doing and would like to load the library without preloading, you can disable   this check with: 
    SET timescaledb.allow_install_without_preload = 'on';

STATEMENT:  CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

And consequently that's why create_hypertable fails.

Starting TimescaleDB via Docker run works for me without any issues. I also tried to put aftermentioned postgres -c shared_preload_libraries=timescaledb command to Dockerfile, but it did not help.

Am I missing something? How are you doing your Docker compose?

Thanks in advance.

Best wishes,
Martin

Design/status/roadmap on the clustered version?

It is mentioned in the FAQ that the clustered version is in active development. Can you share more details on the design, status, or roadmap? The technical paper doesn't seem to shed much light on this to me. Am I missing anything?

Anyway, great job TimescaleDB!

Dropping schema after CREATE EXTENSION leads to bad state

CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
NOTICE:  installing required extension "postgres_fdw"
CREATE EXTENSION
DROP SCHEMA public CASCADE;
NOTICE:  drop cascades to 2 other objects
DETAIL:  drop cascades to extension postgres_fdw
drop cascades to extension timescaledb
DROP SCHEMA
\d
ERROR:  could not open relation with OID 16439

PRIMARY KEYs and UNIQUE constraints not handled correctly by ALTER TABLE

I'm observing an error when trying to create a new hypertable from an existing table - following the instructions at http://docs.timescale.com/getting-started/setup/migrate-from-postgresql#same-db

CREATE TABLE my_new_table (LIKE my_old_table INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES);

SELECT create_hypertable('my_new_table', 'my_timestamptz');

ERROR:  Cannot create a unique index without the column: my_timestamptz (used in partitioning)
CONTEXT:  PL/pgSQL function _timescaledb_internal.get_general_index_definition(regclass,regclass,_timescaledb_catalog.hypertable) line 33 at RAISE
SQL statement "SELECT 1
    FROM pg_index,
    LATERAL _timescaledb_internal.add_index(
        hypertable_row.id,
        hypertable_row.schema_name,
        (SELECT relname FROM pg_class WHERE oid = indexrelid::regclass),
        _timescaledb_internal.get_general_index_definition(indexrelid, indrelid, hypertable_row)
    )
    WHERE indrelid = main_table"
PL/pgSQL function public.create_hypertable(regclass,name,name,integer,name,name,bigint,boolean,boolean) line 87 at PERFORM

However the hypertable creation succeeds if I omit the constraints and indexes in the create table like statement:

CREATE TABLE my_new_table (LIKE my_old_table INCLUDING DEFAULTS EXCLUDING CONSTRAINTS EXCLUDING INDEXES);

Is this expected behaviour ? The docs suggest it is possible to convert an empty table with constraints and indexes.

Exporting data

I know I can do a backup with timescale db (here), but my use case is different. I want to export data from a table, with the COPY FROM instruction in sql :

COPY (SELECT * FROM sensor_climate) TO '/data_export/sensor_climate.bak' With CSV quote

and then insert those data in another database:

COPY sensor_climate FROM '/data_export/sensor_climate.bak' DELIMITER ',' CSV;

But it does not work with an hypertable ! There is only a generic error message, and it works perfectly with other tables (wich are non-hypertables).

[Edit] The error message I get:

fuldatabase=# copy sensor_climate from '/shared_volume/sensor_climate.bak' csv quote;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.

Also, the server tells me:

Server process (PID xx) was terminated by signal 11

If you see a better way to do what I want, please tell me. However, if timescaledb is built for IOT, it is a really important feature being able to export data easily.

For example I have some sensors in a location A with a timescaledb A, and other sensors in a different location B with timescaledb B. I need to export data periodically on a timescaledb C. Actually, it seems that I can't do that.

SELECT setup_db(); failed

tutotsdb=# select setup_db();
ERREUR:  une valeur NULL viole la contrainte NOT NULL de la colonne « port »
DETAIL:  La ligne en échec contient (tutotsdb, pierre-vbox, null, tutotsdb)
CONTEXT:  instruction SQL « INSERT INTO _timescaledb_catalog.meta (database_name, hostname, port, server_name)
        VALUES (database_name, hostname, port, database_name) »
fonction PL/pgsql set_meta(text,integer,name,text,text), ligne 13 à instruction SQL
instruction SQL « SELECT set_meta(hostname, port, database, username, password) »
fonction PL/pgsql setup_db(name,text,text,text,integer), ligne 11 à PERFORM

(Hand made) translation :

ERRROR: a NULL value violates the NOT NULL constraint of the column "port"
DETAIL: Failure line contains (tutotsdb, pierre-vbox, null, tutotsdb)
...

Installing via Homebrew on Linux

Description:
Hitting installation issue (see below) against:

  1. ubuntu: 14.04
  2. Homebrew: 1.2.0

screen shot 2017-06-05 at 12 15 37 pm

ubuntu@ip-172-31-16-101:~$ brew install timescaledb ==> Installing timescaledb from timescale/tap ==> Downloading https://timescalereleases.blob.core.windows.net/homebrew/timescaledb-0.0.11-beta.tar.gz Already downloaded: /home/ubuntu/.cache/Homebrew/timescaledb-0.0.11-beta.tar.gz ==> make ==> make install DESTDIR=/tmp/timescaledb-20170605-5821-1spkl5u/timescaledb/stage Warning: tried to install empty array to /home/ubuntu/.linuxbrew/Cellar/timescaledb/0.0.11-beta/lib/postgresql Warning: tried to install empty array to /home/ubuntu/.linuxbrew/Cellar/timescaledb/0.0.11-beta/share/postgresql/extension Error: Empty installation

Error on alter table

When adding a column with if not exists below error is received .

postgres=# CREATE TABLE my_ht (time bigint, val integer);
CREATE TABLE
postgres=# SELECT * FROM create_hypertable('my_ht', 'time');
 create_hypertable 
-------------------
 
(1 row)

postgres=# ALTER TABLE my_ht ADD COLUMN val2 integer;
ALTER TABLE
postgres=# ALTER TABLE my_ht ADD COLUMN val2 integer;
ERROR:  column "val2" of relation "my_ht" already exists
postgres=# ALTER TABLE my_ht ADD COLUMN IF NOT EXISTS val3 integer;
ALTER TABLE
postgres=# ALTER TABLE my_ht ADD COLUMN IF NOT EXISTS val3 integer;
NOTICE:  column "val3" of relation "my_ht" already exists, skipping
ERROR:  Unknown alter table action on my_ht
CONTEXT:  PL/pgSQL function _timescaledb_internal.ddl_process_alter_table() line 101 at RAISE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.