MySQL Forums
Forum List  »  Stored Procedures

Where Clause Performance
Posted by: Manhao Chen
Date: September 17, 2014 09:10PM

2 Questions from me here

SELECT *
FROM _tbl_customer_

SELECT *
FROM _tbl_customer_
WHERE 1=1

would there be a speed/performance between the above 2 statement

reason i'm asking that i'm writing a SP which looks like this

SELECT *
FROM _tbl_customer_
WHERE IF(inputParameter1 IS NULL, 1=1, _tbl_customer_.deleted = inputParameter1)

wanting to write a SP and will query the table accordingly

so the goal is..

inputParameter1 = null : return all records of the table
inputParameter1 = 1 : only return records that are flag for delete
inputParameter1 = 0 : only return all live records

hope this makes sense, anyone know the best approach?

Options: ReplyQuote


Subject
Views
Written By
Posted
Where Clause Performance
2356
September 17, 2014 09:10PM
1067
September 18, 2014 11:11AM
1044
September 18, 2014 04:55PM
964
September 18, 2014 08:01PM
1131
September 19, 2014 03:38PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.