Abstract. In this paper we describe the OnEQL system, a query engine that implements optimization techniques and evaluation strategies to speed up the evaluation time of querying and reasoning services in the Semantic Web. To identify execution plans that reduce the cost of evaluating a query, we developed a twofold optimization strategy that combines cost-based optimization and Magic Sets techniques. In the first stage, a dynamic programming-based algorithm is used to identify an ordering of predicates in the query that minimizes its estimated evaluation cost. In the second stage, Magic Sets techniques are used to push down query selections into the OnEQL ontology representation, in order to reduce the number of facts inferred during query evaluation. Additionally, we developed three physical operators that execute the sideways passing of bindings during the evaluation of the execution plan. To illustrate the advantages of this approach, we report the results of an experimental study ...