Statistics for The efficient evaluation of visual queries within a logic-based framework