0

Is there a way to create a program to rewrite a query in an optimal form. If so, how? What can I do to implement this.


Rewrite

SELECT EMPOYEE.EMPNO, POSITION
FROM EMPLOYEE E, JOBHISTORY J
WHERE E.EMPNO = J.EMPNO
AND STARTDATE <= ENDDATE
AND SALARY <= 3000

into

SELECT EMPLOYEE.EMPNO, POSITION
FROM EMPLOYEE E, JOBHISTORY J
WHERE E.EMPNO = J.EMPNO
AND SALARY <= 3000;


because "AND STARTDATE <= ENDDATE is not needed in the first query.

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by crishjeny
0

There is no rule of thumb to follow to optimize a query.

and what you are trying to do is not optimization, but removing some requirements.

0

How do you decide if a clause is needed in a query or not? If you have a rule for that, you can code it. But from your example this rule would have to rely on semantic knowledge rather on formal aspects of the query.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.