if we are not using dynamic query, will a static query with if condition cause the query to run slow?Since you are asking the question, probably.
One solution is to use a dynamic query in which the query is simplified before the query is opened.
DEFINE vWhere AS CHARACTER NO-UNDO.
DEFINE QUERY qCustomer FOR Customer SCROLLING.
vWhere = "FOR EACH Customer WHERE ...".
QUERY qCustomer:QUERY-PREPARE(vWhere).
QUERY qCustomer:QUERY-OPEN().
REPEAT:
GET NEXT qCustomer.
IF NOT AVAILABLE Customer THEN LEAVE.
DISPLAY Customer.NAME.
END.
QUERY qCustomer:QUERY-CLOSE().