Live data from Hacker News

Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

blog.timescale.com

111–120 of 184 posts

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#111
post #105

Earlier quoted context omitted.

Thank you for your prompt response! I think the most important thing is Clickhouse is NOT designed for small batch insertion, if you need to do 1000s of Inserts/sec you do queue in front of clickhouse. And query speed can be impacted by batch side a lot. So have you looked at query performance with optimal batch size ?

Yep! The blog post includes data and graphs from both large (5000-15,000 rows / batch) and small (100-500 rows / batch) sizes. Please see the section "Insert Performance". Thanks! https://blog.timescale.com/blog/what-is-clickhouse-how-does-...

1) This is also small batch size. If you're inserting 500.000 rows/sec 5000 rows is not particularly large batch size

2) I see different graphs for ingest but not for queries. The data layout will depend on the batch size, unless of course you did OPTIMIZE before running queries

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#112

Disclaimer: I'm a co-founder of https://logtail.com , ClickHouse-based hosted log management platform. PostgreSQL, TimescaleDB, and ClickHouse are all impressive pieces of software. We use both PostgreSQL and ClickHouse at Logtail. ClickHouse shines for true OLAP use-cases and is very hard to beat performance-wise when configured properly. Example: > Poor inserts and much higher disk usage (e.g., 2.7x higher disk usa…

Could you explain what you mean by ops heavy? Just curious. Actually have a production system where Timescale as well as clickhouse are running in parallel. So far clickhouse didn't do any trouble, but it is rarely used right now.

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#113

We've got a few billion rows in TSDB, pretty happy with it so far. Our workload fits the OLTP workflow more than OLAP though, we're processing / analyzing individual data points from IoT devices as they come in, and then providing various visualizations. This tends to mean that we're doing lots of fetches to relatively small subsets of the data at a time, vs trying to compute summaries of large subsets. Compression i…

> Compression is seriously impressive Does this effect your query performance ?

In practice we've seen it actually improve performance, because when fetching a data range for a device fewer actual rows have to be fetched from the disk. You pick certain columns (like device ID) that remain uncompressed and indexed for rapid querying, and then the actual value columns are compressed for a range of time.

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#114
Can somebody recommend a database suitable for an event sourced application:

* One series of events per user

* Each series grows at about 10 events/minute while the user is active

* Fancy queries are not required, typically a user's event series is consumed in order to update aggregate state for that user

* Either used online, adding events one at a time and needing to immediately update the aggregate state

* Used offline syncing a batch of hours or days at once. When a large time interval, eventually consistent state updates are acceptable

* It must be possible to delete a user's data, regardless how old it is (a nightly batch job deleting multiple users at once is fine, if it helps performance)

* Migrating old data should be possible with reasonable performance and without consuming excessive temporary memory

* Compact storage is important (simple zstd compression should suffice, though columnar compression might be slightly better)

* Being able to use a cheaper object store like S3 for old data would be nice

At a glance timescale community appears to meet most requirements. The userid can be used as `segmentby` key, and the data compressed via columnar compression. But it seems to have limitations with migration (sounds like it requires me to manually decompress and recompress chunks, instead of simply transforming one (chunk, segment) piece at a time) and deletion (I need to delete everything with a specific `segmentby` key).

Alternatively there is the DIY approach, of serializing each entry in a compact format, one file per user, and then once data is old enough compress it (e.g. with zstd) and upload it to S3.

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#115
post #75
post #41

Earlier quoted context omitted.

We're using TimescaleDB to store log events - so each row has a timestamp, some properties, and a log message. And a lot of that is actually in a JSONB column. Not the archetypal time series use case, but TimescaleDB is still really useful. TSDB's compression means we can store a huge volume of data in a fraction of the space of a standard Postgres table. You can achieve even better compression ratios and performance…

So services like Sentry / Honeybadger / etc probably use this architecture?

I think most online logging SaaS services actually use ElasticSearch.

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#116

It would be awesome to combine the following things: * PostGIS * Timescale * Citus * Zedstore This truly would be the relational DB to end all relational DBs. Unfortunately, we run into a couple problems: * Managing multiple extensions is a burdensome task, which should be in the wheelhouse of cloud providers, but... * Timescale and Citus are are open core, holding back features for customers. Their primary revenue c…

If you use Aiven for a cloud PG instance you can do both Timescale + PostGIS installed. I also really wish ClickHouse would prioritize PostGIS support - IIRC it has been on their roadmap for a while but keeps getting kicked around every year or so. Same thing with CockroachDB - PostGIS support kicked down the road every year.

Hi there, CockroachDB dev here. We've supported spatial features from PostGIS since 20.2 - you can get started here https://www.cockroachlabs.com/docs/stable/spatial-data.html! Of course, there's bits and pieces we've missed but if there's something you're missing in particular you can let me know here or through a GitHub issue.

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#117
post #107

Our anecdata: we store telemetry per thing. After loading a month worth of data - timescaldb as hosted by their cloud ran a difference aggregation in seconds. Clickhouse routinely did it in 20 millis. Simple avg, etc were better, but always clickhouse was an order of magnitude faster than timescale. We didn't invest a whole bunch into optimization other than trying some indexing strategies in timescaledb. So for our…

From my experience of benchmarking these databases on scientific data (highly regular timeseries) and looking at the internals of both, these kinds types of number happen when answering the query needs crunching through many rows, but the output has few. i.e. the queries are filtering and/or aggregating a ton of input rows, that can't be excluded by indexes or queried from preaggregations. From what I can tell it com…

(post author)

You do a great job summarizing some of the benefits of ClickHouse we mentioned in the post, including the vectorized engine!

That said, I'm not sure I'd refer to PostgreSQL/TimescaleDB engine architecture as resembling IE6 JS support. Obviously YMMV, but every release of PG and TimescaleDB bring new advancements to query optimizations for the architecture they are designed for, which was the focus of the post.

I'm personally still impressed, after 20+ years of working with SQL, relational databases, when any optimization engine can use statistics to find the "best" plan among (potentially) thousands in a few ms. Maybe I'm too easily impressed. :-D

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#118

Can somebody recommend a database suitable for an event sourced application: * One series of events per user * Each series grows at about 10 events/minute while the user is active * Fancy queries are not required, typically a user's event series is consumed in order to update aggregate state for that user * Either used online, adding events one at a time and needing to immediately update the aggregate state * Used of…

(post author and Timescaler)

What do you mean by "migrating old data"? Don't want to make assumptions before answering further.

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#119

That’s a really thorough comparison. Much more detailed than I expected. From what I see, the trade off in disk space usage would point me toward Timescale for most of my workloads. The insert performance tradeoff just wouldn’t justify the difference for me.

Does the disk usage go down later once the numerous parts are merged or not? I would assume it does but reading the article implies that it does not.

Great question. Yes, eventually it does, but (at least for now) it wasn't something we could reliably force as part of the query cycle and know everything was in it's "best" state with ClickHouse. To be honest, we didn't provide the final compressed size of either database because of the need to wait.

The code that's currently used by TSBS was submitted by Altinity, a heavy supporter of ClickHouse in the U.S., but TSBS is open source and anyone is welcome to contribute and make the process/test better!

Re: Comparing ClickHouse to PostgreSQL and TimescaleDB for time-series data

#120

Can somebody recommend a database suitable for an event sourced application: * One series of events per user * Each series grows at about 10 events/minute while the user is active * Fancy queries are not required, typically a user's event series is consumed in order to update aggregate state for that user * Either used online, adding events one at a time and needing to immediately update the aggregate state * Used of…

(post author and Timescaler) What do you mean by "migrating old data"? Don't want to make assumptions before answering further.

Updating many/all rows as a rare maintenance task, typically as part of deploying a new version of the application.

I know timescale has native support for the most common cases (adding nullable columns/renaming columns). But sometimes the transformation is more complex. Sometimes an sql update statement would suffice, sometimes streaming each segment in chronological order to the application returning the updated row might be required.

Post reply on HN