Live data from Hacker News

Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

arunsori.me

21–28 of 28 posts

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#21
post #12

Earlier quoted context omitted.

I only just discovered foreign data wrappers today but it seems like you can write these in python though right? Might be easier than using Go to interface with C.

Messagebird uses Go on the backend; I suspect that's why they wrote the FDW in Go.

Hi, Author here!

Yes, your hypothesis is correct. We chose Go, mostly because almost all of us were quite familiar with it and there weren't many C experts :)

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#23
post #19
post #14

I wonder if you've benchmarked your Go implementation against the Percona Lab's FDW for Clickhouse? https://github.com/Percona-Lab/clickhousedb_fdw

There's now also a more recent CH FDW written in C by the team at adjust, https://github.com/adjust/clickhouse_fdw

Good find, looks like a more up to date fork of the Percona FDW.

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#24
post #20
post #14

I wonder if you've benchmarked your Go implementation against the Percona Lab's FDW for Clickhouse? https://github.com/Percona-Lab/clickhousedb_fdw

Hi, Author here. I have to admit, I haven't done any benchmarking against the existing FDWs for Clickhouse. But I actually wrote the Go FDW 2 years ago(around Dec 2018). ;) There weren't any Clickhouse FDW available at that time and I probably would've tried them as well. Now I just got around to write the blog post and convincing the team to release the code. Though I have a suspicion that the percona FDW might win…

Thanks for the reply. I really appreciate your post and the additional FDW. If you ever decide to give it a go, a benchmark would be interesting, if for no other reason than to see how much penalty cgo actually incurs vs possible efficiency gains in your implementation strategy.

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#25
post #24
post #20

Earlier quoted context omitted.

Hi, Author here. I have to admit, I haven't done any benchmarking against the existing FDWs for Clickhouse. But I actually wrote the Go FDW 2 years ago(around Dec 2018). ;) There weren't any Clickhouse FDW available at that time and I probably would've tried them as well. Now I just got around to write the blog post and convincing the team to release the code. Though I have a suspicion that the percona FDW might win…

Thanks for the reply. I really appreciate your post and the additional FDW. If you ever decide to give it a go, a benchmark would be interesting, if for no other reason than to see how much penalty cgo actually incurs vs possible efficiency gains in your implementation strategy.

Yes for sure. Definitely a benchmark would be a very solid approach to see the efficiency differences.

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#26

I sometimes fondly remember my time as an office hero, using MSAccess to attach to just about any data source imaginable, copy to a temptable and run whatever cleaning was required before loading into the server database. Good times; almost 25 years ago now. Sometimes I wonder if we're stuck.

I had actually considered doing this recently with a new hire. I purchased them a license with Access included, but ai have not had time to play with it to talk to MySQL 5.6.

It is embarrassingly easy, once you get over the (minimal) hurdle of setting up the ODBC connections, docs over here for MySQL 5.6: https://dev.mysql.com/doc/connector-odbc/en/

In MSAccess, just go to "External Data" -> "New Data Source" -> "From Other Sources" -> "ODBC Databases" (chose whether to link or import the data) and then create a new data source under "Machine Data Sources" using the MySQL driver.

It became like muscle memory after a while :-)

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#27
post #23
post #19

Earlier quoted context omitted.

There's now also a more recent CH FDW written in C by the team at adjust, https://github.com/adjust/clickhouse_fdw

Good find, looks like a more up to date fork of the Percona FDW.

Yeah, the original Percona FDW hasn't been active for a while, only had a few commits after the first release and was missing quite a few features. Also doesn't support anything more recent than Postgres 11.

So the "adjust" CH FDW is the only usable choice today, thankfully quite actively maintained, primarily by the Adjust devs. I'd presume it's used for their production load.

Re: Writing a Postgres Foreign Data Wrapper for Clickhouse in Go

#28
post #2

This is really cool. I had not heard of Foreign Data Wrappers for Postgres before! Are these used in production commonly or more of a toy thing?

It's been used quite a lot, especially when dealing with legacy databases or having to support multiple databases with a single codebase.

There is one concern though. Both Google Cloud SQL and AWS RDS support only postgres_fdw, so one should manage their own storage, cluster and backups.

Post reply on HN