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

How can I time a code segment for testing performance with Pythons timeit?

You can use time.time() or time.clock() before and after the block you want to time. import time t0 = time.time() code_block t1 = time.time() total = t1-t0 This method is not as exact as timeit (it does not average several runs) but it is straightforward. time.time() (in Windows and Linux) and time.clock() (in Linux) are … Read more

Optimise PostgreSQL for fast testing

First, always use the latest version of PostgreSQL. Performance improvements are always coming, so you’re probably wasting your time if you’re tuning an old version. For example, PostgreSQL 9.2 significantly improves the speed of TRUNCATE and of course adds index-only scans. Even minor releases should always be followed; see the version policy. Don’ts Do NOT … Read more