Optimized database queries in ganetiviz views.
Refs #13569