HPCC-9786 Optimize looking up associations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Merge branch 'issue9786' into candidate-4.0.2

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>