TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: BSON Extension for Postgres

115 pointsby buzzmover 1 year ago
JSON support in postgres is superb but sometimes you really want decimal, date, and binary types, "carefree" UTF8 string handling (i.e. no escaping), and robust roundtrippability. So I made an extension for BSON.

8 comments

ccleveover 1 year ago
The code here is really well designed. This project can serve as a tutorial on how to build a Postgres extension. Have a look at this:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;buzzm&#x2F;postgresbson&#x2F;blob&#x2F;main&#x2F;pgbson--2.0.sql">https:&#x2F;&#x2F;github.com&#x2F;buzzm&#x2F;postgresbson&#x2F;blob&#x2F;main&#x2F;pgbson--2.0....</a><p>and this:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;buzzm&#x2F;postgresbson&#x2F;blob&#x2F;main&#x2F;pgbson.c">https:&#x2F;&#x2F;github.com&#x2F;buzzm&#x2F;postgresbson&#x2F;blob&#x2F;main&#x2F;pgbson.c</a><p>Really nice stuff.
hnto_picsover 1 year ago
That&#x27;s the first time I hear of BSON. How does this compare to cbor and messagepack?
评论 #39020383 未加载
评论 #39018474 未加载
lxeover 1 year ago
Why BSON and not JSONB, which is already supported in Postgres?
评论 #39015108 未加载
评论 #39015112 未加载
评论 #39015099 未加载
eddd-dddeover 1 year ago
This is really cool. A common use case for me is building JSON objects directly in my query, for example to return a list of json objects. Usually this means date columns lose their type, is there a way of returning bson like with jsonb_build_object that keeps this types?
vvpanover 1 year ago
Perhaps this is an opportunity to ask somebody who might know about BSON performance. As a POC&#x2F;stress test for work I added two multi-GB datasets to Postgres (as JSONB) and to Mongo (BSON). While trying to query approximately a hundred megabytes of data (a few hundred documents) from each I found that Postgres executed the query and decoded the JSON data in under a second, while it took Mongo a few seconds. Does this mean that BSON is slow to deserialize? Or perhaps it is not related to serialization? I was quite confused.
评论 #39018126 未加载
dsizzleover 1 year ago
Listed status is &quot;experimental&quot; but only two relatively minor commits in the last two years. Maybe it&#x27;s more stable than that implies or the author is looking to pick it back up?
hanszarkovover 1 year ago
I&#x27;ve used the BSON Java ObjectId for distributed primary key generation for a long time. Really useful for distributed systems.
评论 #39032388 未加载
pellaover 1 year ago
As I understand it, it was &#x27;Tested using Postgres 14.4&#x27;.<p>I&#x27;m wondering if there are any plans to support Postgres versions 15 and 16?
评论 #39031615 未加载
评论 #39022047 未加载