Get rid of useless db indices and imrpove index ordering
Both postesql and mysql know how to use partial indices, so there is no need to have multiple indices to cover the same columns.
Additionally, in some cases the indices order can be improved, e.g. for polymorphic relations, first index the relation type then the id.
Fixes #24256 - Optimize DB indices
This removes some indices that aren't really needed since they are
already covered by parts of another index - both PostgreSQL and MySQL
know how to use a subset of a multi-column index.
Additionally, a few polymorphic indices were reversed in order so
that the type column is indexed before the id column.
A couple of duplicate indices were also deleted.