Add indexes to speed up queries

Select queries were extremely slow in a database with some million
entries, taking up to 30 seconds per query. Adding indexes for the most
commonly queried fields reduces this time to less than one second per
query.

The index creation command for postgresql is not as "clean" as the one
used for H2, but this is the price to pay for compatibility with legacy
versions. The 'IF NOT EXISTS' clause was introduced only in version 9.5
while the command used in this change is compatible with any version >=
9.x.

Change-Id: I7da13aaf19142325a3bba3bf0117871708a0bd90
2 files changed