CA-98944: Reduced db access

... get_internal_where calls

Signed-off-by: Vincent Bernardoff <vincent.bernardoff@citrix.com>