core: CalculateStorageUsage psql function refactoring.
core: CalculateStorageUsage psql function refactoring.

CalculateStorageUsage psql function was joining tables that were already
joined by images_storage_domain_view, also- executed almost the same query
twice- while it could be consolidated into one query by adding a simple
condition.

This patch changes the query to select only from
images_storage_domain_view, and consolidating the two queries.

Change-Id: I3997cb4f310ca8ebaf8d36f9ffae1d126fa7de00
Signed-off-by: Amit Aviram <41538b01504cea1528cb71aa0ca1ef3f1b219012@redhat.com>

OpenUniversity/ovirt-engine,OpenUniversity/ovirt-engine,OpenUniversity/ovirt-engine,OpenUniversity/ovirt-engine,OpenUniversity/ovirt-engine