Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get timescaledb version of the database

Tags:

timescaledb

According to the docs:

TimescaleDB supports having different extension versions on different databases within the same PostgreSQL instance.

I can get the installed version of the instance with this SQL command:

SELECT extversion
FROM pg_extension
where extname = 'timescaledb';

But how can I get the version of a specific database?

Notes:

  • I prefer to get the version via sql (not psql)
  • the reason for this is that we'd like to know if we must update the datebase (i.e. execute ALTER EXTENSION timescaledb UPDATE;) or not
like image 281
TmTron Avatar asked Aug 19 '19 09:08

TmTron


People also ask

What is TimescaleDB in PostgreSQL?

TimescaleDB is an open-source time series database developed by Timescale Inc. It is written in C and extends PostgreSQL. TimescaleDB supports standard SQL queries and is a relational database.


1 Answers

Turns out, that my assumption was wrong:

SELECT extversion
FROM pg_extension
where extname = 'timescaledb';

returns the version of the currently connected database.

Here is how we can find out the versions:

SELECT default_version, installed_version FROM pg_available_extensions
where name = 'timescaledb';
  • default_version: is the version installed in the PostgreSQL server instance
  • installed_version: is the version that the current database is using

Example:

When the extension used by the database is not up-to-date, the versions do not match:

SELECT default_version, installed_version FROM pg_available_extensions
where name = 'timescaledb';

 default_version | installed_version 
-----------------+-------------------
 1.4.1           | 1.4.0

now update the extension

  • connect via psql -X -U USER -W -D DBNAME
  • execute ALTER EXTENSION timescaledb UPDATE;
  • now the versions are the same
like image 166
TmTron Avatar answered Sep 23 '22 15:09

TmTron