I have a view ( viewX) based on joins of some tables:
When I use WHERE, the request is delayed, CPU usage goes up to 50%, and finally I need to close the service mysqld.exeand restart to try to solve the problem again.
When I use HAVING, the query runs fine and fast, I get the results and you're done.
The request is similar to this:
SELECT * FROM viewX WHERE column_of_view = 'foo'
SELECT * FROM viewX HAVING column_of_view = 'foo'
What's happening?
The solution I found is to do something like this:
SELECT * FROM (SELECT * FROM viewX) as T WHERE column_of_view = 'foo'
SELECT * FROM (SELECT * FROM viewX) as T HAVING column_of_view = 'foo'
GENERAL ISSUES WORK TRUE, BUT, I think this is BAD! (SELECT * FROM (... viewX) ????)
source
share