News for hackers. Stuff that matters.
Re:Microsoft open sources PostgreSQL extensions to muscle in... by Thaxll on Tuesday February 11, 2025 @09:24AM (#43013008)
It's very painful to use JSON with regular SQL drivers, MongoDB driver is much better overall than regular SQL from a programmer perspective.
Re:Microsoft open sources PostgreSQL extensions to muscle in... by dtech on Tuesday February 11, 2025 @10:03AM (#43013552)
Which language? In Java (/the JVM) it's perfectly fine while Mongo is a PITA
Re:Microsoft open sources PostgreSQL extensions to muscle in... by nonethewiser on Tuesday February 11, 2025 @10:13AM (#43013704)
working with JSONB in Postgres is painful.

It's powerful, I love that it's there, but actually using it is always such a chore.

Re:Microsoft open sources PostgreSQL extensions to muscle in... by krashidov on Tuesday February 11, 2025 @12:53PM (#43015814)
Genuinely curious, what do you find painful about it? Is it the syntax? Performance? Or does it just encourage bad practices?
Re:Microsoft open sources PostgreSQL extensions to muscle in... by javaunsafe2019 on Tuesday February 11, 2025 @02:28PM (#43017194)
I also don't get it - it's super easy to write queries with it. Please elaborate...
Re:Microsoft open sources PostgreSQL extensions to muscle in... by nonethewiser on Tuesday February 11, 2025 @06:03PM (#43019511)
stuff like this

SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @> '{"tags": ["qui"]}';

or

SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @? '$.tags[*] ? (@ == "qui")';

which find documents in which the key "tags" contains array element "qui"

https://www.postgresql.org/docs/current/datatype-json.html

Re:Microsoft open sources PostgreSQL extensions to muscle in... by Tostino on Tuesday February 11, 2025 @08:20PM (#43020648)
I had to ask Claude because I've never worked with Mongo, but apparently the equivalent query for MongoDB is:

    db.api.find(
      { "tags": "qui" },
      { 
        "guid": 1, 
        "name": 1,
        "_id": 0
      }
    )
Re:Microsoft open sources PostgreSQL extensions to muscle in... by nonethewiser on Tuesday February 11, 2025 @08:31PM (#43020740)
It's fair to compare alternatives but to be clear I'm not saying postgres JSONB is worse than mongo. I'm not very familiar with mongo either. Im saying it can be tedious is absolute terms. I did not assume this to be universal to document dbs but perhaps it could be. Although your example does seem simpler.
Re:Microsoft open sources PostgreSQL extensions to muscle in... by javaunsafe2019 on Tuesday February 11, 2025 @09:27AM (#43013040)
Wait what? Writing mongo queries vs SQL is a pain in my experience…