I have a MySQL 8 table that has several million records, around 40m
I run very frequently, specially while debugging, a query that has to exclude several “names” from that table and then group by it, so I use the “NOT LIKE” statement on the where part, is this the most performant/wise thing to do or is there something better?
The column in question is QNAME on this example, type varchar(48)
The query is not super slow, but when add this filter you clearly see a 60-90 sec time increase, because of course i believe its very ineffective.
SELECT
...
FROM
...
WHERE
DATE_FORMAT(CREATIONDTE, '%Y-%m-%d') = DATE_FORMAT(CURDATE(), '%Y-%m-%d')
AND NOT (QNAME LIKE '%IR360%' OR QNAME LIKE '%DEAD%' OR QNAME LIKE 'SYSTEM%' OR QNAME LIKE '%.BO')
GROUP BY
QNAME