News for hackers. Stuff that matters.
Re:A pure Go embedded SQL database by anderspitman on Saturday January 29, 2022 @06:00PM (#30131485)
It's pretty easy to statically link SQLite[0]. Are there other disadvantages to CGO?

[0]: https://www.arp242.net/static-go.html

Re:A pure Go embedded SQL database by vbitz on Saturday January 29, 2022 @07:10PM (#30132061)
Without additional configuration cgo breaks cross-compilation.
Re:A pure Go embedded SQL database by anderspitman on Sunday January 30, 2022 @02:24AM (#30134834)
Oh right how could I forget that.
Re:A pure Go embedded SQL database by christophilus on Saturday January 29, 2022 @06:08PM (#30131544)
Yes. It doesn’t play nice with goroutines and Go’s concurrency model, from what I understand.
Re:A pure Go embedded SQL database by eloff on Saturday January 29, 2022 @06:50PM (#30131886)
Yes, function calls across the boundary are slow. It's fine if the functions do lots of work, it's very expensive for function calls that should be cheap.

For sqlite it might not matter too much, since any query does quite a bit of work.

Re:A pure Go embedded SQL database by throwaway894345 on Saturday January 29, 2022 @07:36PM (#30132274)
Agreed. I wouldn't be surprised if a pure-Go alternative would be slower. Someone remarked upthread that the same author wrote a C-to-Go transpiler specifically to make a pure-Go sqlite and it was (somewhat unsurprisingly) considerably slower than the CGo version. It's possible (and to an extent, likely) that the transpolar was generating suboptimal Go code, but I would wager that a hand-written version would also be slower.
Re:A pure Go embedded SQL database by azinman2 on Saturday January 29, 2022 @08:11PM (#30132581)
A query may do a lot of work but iterating over many results could be very slow.
Re:A pure Go embedded SQL database by eloff on Saturday January 29, 2022 @09:44PM (#30133345)
Yes, the API is probably suboptimal for Go. It's better to make a wrapper that does the query and fetches many results in one call, into a Go buffer.