[FAB-8033] Optimize DB queries
[FAB-8033] Optimize DB queries

Database queries optimized to make fewer calls to the
database.

Change-Id: I84b1c4780007283654003eb9bd677d3e226e5aaa
Signed-off-by: Saad Karim <d1da09defa5b48f678dafc09ede657abebbe94c4@us.ibm.com>

saadk10/fabric-ca,saadk10/fabric-ca