id_mapping_api was designed to make a query per entity to fetch
public ids. This lead to a very poor performance when there were many
entries in LDAP. For example, for 15k entries 15k MySQL queries were
required. For the first run 15k INSERTs were required, which makes
things even worse.
Change this behavior to fetch related mappings from MySQL as a list and
perform the necessary join in-memory.
bp ldap-preprocessing
Partial-Bug: 1582585
Change-Id: I2c266e91f2f05be760f8a3eea3738868243cc9c6