Pick PostgreSQL when your data is related and constrained, and MongoDB when records are self-contained documents whose shape changes often.
On 200,000 jsonb documents, an expression index cut a single-field lookup from 11.4 ms to 0.3 ms on PostgreSQL 18.1.
MongoDB's server uses the SSPL, which the Open Source Initiative does not treat as open source, while FerretDB 2.x offers an Apache 2.0 MongoDB-compatible layer on PostgreSQL.