Semantic Query Optimization: from DBMS to KBS