When is Ontology-Mediated Querying Efficient?