pglite icon indicating copy to clipboard operation
pglite copied to clipboard

Timeseries extensions

Open beriberikix opened this issue 1 year ago • 4 comments

Would it be possible to support timeseries extensions like pg_timeseries or timescale?

I have a use case for building a local-first charting app and having good time series support is key.

Thank you!

beriberikix avatar Sep 02 '24 14:09 beriberikix

We'd love to support some time series extensions.

Our current focus is to make building extensions easer for the community. We intent to maintain a few core extensions ourselves but hope that the community can help to with others. Docs are coming.

samwillis avatar Sep 03 '24 09:09 samwillis

Hey @samwillis I'd like to work on adding support for timescale. If you have any WIP docs or anything, I could try them out, and help reviewing them :)

alejandrodnm avatar Sep 26 '24 13:09 alejandrodnm

I looked into this a bit and found the following steps:

  1. Download the .deb file for timescaledb (you may have to change versions depending on your OS. Also, the next version of pglite uses postgres 17 so you'll have to change that if you use 0.3.0 or greater)
wget -O timescale.deb --content-disposition \
  "https://packagecloud.io/timescale/timescaledb/packages/ubuntu/jammy/\
timescaledb-2-postgresql-16_2.19.3~ubuntu22.04_amd64.deb/download.deb"
  1. Convert the .deb to a .tar.gz (creates a temporary folder)
dpkg -x timescale.deb ./tmp
tar -czf timescale.tar.gz -C tmp $(find tmp -type f | sed 's|^tmp/||')
  1. Load the extension in your pglite
const db = new PGlite("memory://", {
  extensions: {
    timescaledb: new URL("./timescale.tar.gz", import.meta.url),
  }
});

Unfortunately, this step here fails with

error: Uncaught (in promise) ErrnoError {
  name: "ErrnoError",
  errno: 44,
  stack: "<generic error, no stack>"
}
  1. Load the extension in your .sql
CREATE EXTENSION IF NOT EXISTS timescaledb;

SebastienGllmt avatar Apr 20 '25 00:04 SebastienGllmt

@SebastienGllmt

PGlite is a WASM build and therefore any extension needs to be compiled to WASM in order to work.

You downloaded an amd64 (x86_64) version of the plugin, so it cannot work.

One of our goals is to make it easier for the community to contribute extensions to PGlite. We will be looking into that hopefully in the next months, but cannot guarantee anything at the moment.

tdrz avatar Apr 20 '25 08:04 tdrz

Any update on this? would be interested too! (mainly because I use timescale in prod and I would love a local db like pglite for quick unit tests)

maelp avatar Dec 04 '25 11:12 maelp