How to configure MongoDB Java driver MongoOptions for production use?

Updated to 2.9 : autoConnectRetry simply means the driver will automatically attempt to reconnect to the server(s) after unexpected disconnects. In production environments you usually want this set to true. connectionsPerHost are the amount of physical connections a single Mongo instance (it’s singleton so you usually have one per application) can establish to a mongod/mongos … Read more

SELECT DISTINCT is slower than expected on my table in PostgreSQL

While there is no index skip scan in Postgres yet, emulate it: WITH RECURSIVE cte AS ( ( — parentheses required SELECT product_id FROM tickers ORDER BY 1 LIMIT 1 ) UNION ALL SELECT l.* FROM cte c CROSS JOIN LATERAL ( SELECT product_id FROM tickers t WHERE t.product_id > c.product_id — lateral reference ORDER … Read more

Which database design gives better performance?

Generally speaking, data integrity is more important than performance, so denormalize1 only if you have performed measurements on representative amounts of data and the results indicate a strong need for better performance. More often that not, a normalized schema will perform just fine, especially if you got your physical design right (such as indexing). In … Read more

LOWER LIKE vs iLIKE

The answer depends on many factors like Postgres version, encoding and locale – LC_COLLATE in particular. The bare expression lower(description) LIKE ‘%abc%’ is typically a bit faster than description ILIKE ‘%abc%’, and either is a bit faster than the equivalent regular expression: description ~* ‘abc’. This matters for sequential scans where the expression has to … Read more

Multiple schemas versus enormous tables [closed]

I want to see which method is more efficient in terms of querying in the database. In a multi-tenant database, querying is only part of the problem. Other parts of the problem are cost, data isolation and protection, maintenance, and disaster recovery. These are significant; you can’t consider only query efficiency in a multi-tenant database. … Read more