I'm having difficulties to optimize my relatively simple query. The query fetches data from one table that have about 0,5 million rows. I'm using EXISTS clause to fetch the wanted rows and have an index created for that, but the query is still quite slow.
Is there a alternative, faster, way to perform the following SQL?
m1.document_id, m1.document, m1.attribute
EXISTS ( SELECT * FROM myTable m2 WHERE attribute = 'attrName' AND m1.document_id = m2.document_id )
It seems that the EXISTS clause slows down the query dramatically.