userportal: optimize GetAllFromVms query
userportal: optimize GetAllFromVms query

Rewrote the stored function to optimize the query inside GetAllFromVms
Splitting out the boolean for simplicity
Joining instead of using exists on a complicated view
Removing distinct, as it's already inside the joined view

Change-Id: I541c9172c3ba9bcf989f9660baf06ec2e1fd02d7
Bug-Url: https://bugzilla.redhat.com/1151477
Signed-off-by: Tim Speetjens <b3b040041ff80f1d664e538bbfdebd949481b8f2@redhat.com>

walteryang47/ovirt-engine,yingyun001/ovirt-engine,yingyun001/ovirt-engine,OpenUniversity/ovirt-engine,walteryang47/ovirt-engine,yapengsong/ovirt-engine,walteryang47/ovirt-engine,eayun/ovirt-engine,zerodengxinchao/ovirt-engine,yapengsong/ovirt-engine,eayun/ovirt-engine,OpenUniversity/ovirt-engine,yingyun001/ovirt-engine,zerodengxinchao/ovirt-engine,yapengsong/ovirt-engine,OpenUniversity/ovirt-engine,eayun/ovirt-engine,yingyun001/ovirt-engine,zerodengxinchao/ovirt-engine,zerodengxinchao/ovirt-engine,eayun/ovirt-engine,OpenUniversity/ovirt-engine,yapengsong/ovirt-engine,zerodengxinchao/ovirt-engine,eayun/ovirt-engine,walteryang47/ovirt-engine,OpenUniversity/ovirt-engine,yapengsong/ovirt-engine,yingyun001/ovirt-engine,walteryang47/ovirt-engine