Opened 8 years ago
Last modified 8 years ago
#7332 new enhancement
Use `WHERE 1=1` instead of eliminating `WHERE` clause
Reported by: | boonebgorges | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Contributions | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | needs-patch good-first-bug |
Cc: |
Description
Following some discussion with @ninjew in #7290: It would make our query SQL clauses easier to debug and modify if they always contained a WHERE
clause. So the minimal query would be, eg, SELECT * FROM wp_bp_groups WHERE 1=1
instead of SELECT * FROM wp_bp_groups
.
A bit of research suggests that any performance issues should be negligible - it adds a very small amount of overhead to the query planning stage, and is totally ignored during query execution.
For reference, WP_Query
does something similar (though other WP query classes do not).
In 11376: