How TimescaleDB compresses time-series data
Posted by lkanwoqwp 1 day ago
Comments
Comment by gopalv 1 day ago
That section is the most relevant whenever compression in a DB is discussed.
The purpose of a database is to find, aggregate or update data - storage is where the trade-off gets expressed. There are no silver bullets here.
Any method of compression which speeds up either filter rejection or scan rate is better than something that only trades off IO for CPU usage.
For example, dictionary encoding can be slower to read (because you decompress the whole dictionary and not just the skip read after filter), but not if you can squeeze out an IN clause by turning string comparisons into O(1) dictionary followed by a simple integer filter. Remember, this can be arbitrarily complex (Druid is a great example of this) and then the bitmaps can be used because the dictionary index will be a dense 0-N.
Even better if that can feed a deterministic operation like UPPER() so that you do it over the dictionary hits once, instead of each row. You can even use it over the same hash slot, instead of another dictionary collision check or hash computation.
If anyone is looking at JSONB compression, go take a long look at the Variant encoding proposals from Databricks/Snowflake for Iceberg[1].
Turning a single column "payload" JSONB field into chunks which are columnarized and strictly typed allows you to do all the tricks mentioned here, but on loosely typed data but chunk by chunk.
[1] - https://github.com/apache/parquet-format/blob/master/Variant...
Comment by PaulWaldman 1 day ago
Comment by kevinob11 1 day ago
Comment by redwood 23 hours ago
Comment by keynha 1 day ago
Comment by tudorg 1 day ago
This is a project that is simply lot of fun to work on. There are many tricks that can be used to speed-up analytics, besides just type-aware compression:
* for each segment you will keep things like max/min/sum, number of distinct values, bloom filters, etc. For a good amount of common queries, you can answer them just based on this metadata, so you don't need to decompress the columns at all.
* for text column, you compress them differently based on cardinality. Low cardinality (think labels or similar) is dictionary based compression. High cardinality is LZ4.
* Generally the smaller the data on disk, the higher the cold runs performance. This is because you need less IO to load it in memory. I have discovered that on top of the type-aware compression, it's worth doing another round of LZ4. There's also some research that it's sometimes worth doing multiple passes of LZ4.
* Partition and segment pruning. If you can tell from the metadata or bloom filters that the filter doesn't match a partition or segment, you skip the whole thing.
* Push down of filters in the decompression layer. Depending on the compression algorithm, while you decompress you can also filter out the values that you don't need. This avoids passing data and allocating memory for elements that will be later discarded anyway.
* Organization of data on disk is more important than almost anything else. Of course, that's the main point of columnar storage, but there are level of details on how to organize the data so that IO is minimized during queries. I have tried 3-4 different layouts before settling on one.
* For top N type of queries, which are really common in analytics, you want to stop the reading from disk / decompressed as soon as you have enough data to guarantee that you have a correct top N to satisfy the query.
* Parallelize everything: at least ClickBench runs on instances with a lot of CPU cores, so you need to parallelize every step of the way. This is done differently depending on the query type. For example for top N, each worker can take a subset of the segments and get the top N from each of them. Then you combine those in a single result.
Comment by faxmeyourcode 1 day ago
Comment by ddorian43 23 hours ago
Comment by tudorg 17 hours ago
We can't offer Timescale because of the license (except for the version without compression), which blocks some potential customers from using us.
So there is currently no monetization plan beyond reducing this blocker for us. An explicit goal of DeltaX is to be pure OSS, offered on Xata, and also hopefully on all other Postgres providers. Without making any hard promises for the long-term future, I will say I care deeply about it being something that reduces lock-in in the Postgres ecosystem, rather than increasing it.
Comment by frollogaston 18 hours ago
Comment by robocat 1 day ago
TimescaleDB Compression: Hypercore and Columnar Storage with up to 98% Ratio in PostgreSQL
Is the full title.Up to 100% of articles using "up to" in the title are complete dross.
How do I get the job of benevolent dictator of title moderation?
Comment by lkanwoqwp 1 day ago
Comment by heliosAtwork 1 day ago
https://docs.aveva.com/bundle/pi-server-s-da-admin/page/1022...
Comment by lkanwoqwp 1 day ago
But in general now trend is to use normal databases from IT world in OT world to overcome some legacy solutions.
Comment by niltecedu 1 day ago
Someone tell my company this please ;-;
Comment by niltecedu 1 day ago
I think swinging door made sense when storage was slow and scrace, but nowadays storage is cheap (even with these prices)
Comment by blackoil 1 day ago
Comment by f311a 1 day ago
Comment by lokar 1 day ago
I’m still amazed every time I go back and read how the compression for floating point values works.
Comment by drchaim 1 day ago
Comment by ahachete 1 day ago
StackGres is actually the first solution recommended by Timescale for self-hosting with Kubernetes operators [2].
So if you are into Kubernetes (or if not, consider it, using something like K3s [3] is quite straightforward and lightweight on resources), this is probably a great option to self-host which would avoid you all the hassle of manually doing all the setup involved for production-ready clusters.
[2] https://www.tigerdata.com/docs/get-started/choose-your-path/...
[3] https://k3s.io/
Comment by drchaim 23 hours ago
Comment by lkanwoqwp 1 day ago
Comment by drchaim 23 hours ago
Comment by self_awareness 1 day ago
In various distros, the timescaledb installed by the package manager doesn't support other licenses than Apache.
This means that there's a high chance your distro doesn't allow stock timescaledb to use compression. You probably will need to install it manually.
Comment by ClaudiuDasca 17 hours ago
Comment by alamsm99 22 hours ago