0
SELECT email from sending
WHERE `subject` LIKE '%wildcard1%'
AND email  NOT In (SELECT email FROM sending where subject LIKE '%wildcard2%' );

Hi. I ran this query in my phpmyadmin on a 160.000 entries table. Since then, my database and website get stuck anytime i am trying to to access that certain table. The size of the table seems pretty big, too ( 160 MB )

Any idea what the problem is? I was just trying to find emails that received a campaign notification but have not been sent a second notification.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
valiD
  • 351
  • 1
  • 16
  • Possible duplicate of [Best type of indexing when there is LIKE clause](http://stackoverflow.com/questions/41304945/best-type-of-indexing-when-there-is-like-clause) – e4c5 Dec 26 '16 at 14:07

1 Answers1

0

show if a index is on email and try this query:

SELECT s1.email FROM sending s1
WHERE s1.subject LIKE '%wildcard1%'
AND NOT EXISTS (
    SELECT 1 FROM sending s2 
    WHERE s2.email = s1.email 
    AND s2.`subject` LIKE '%wildcard2%');
Bernd Buffen
  • 14,525
  • 2
  • 24
  • 39