WIP: pkg/index: move postgresql to sorted + some fixes

Change-Id: Ia6410256ffe8d4cbc2b9a5c056d075707105ab08