Hi,
On every tables are added indexes on "id", "pid" or "userid" fields.
Removing line
Code:
LEFT JOIN racuni ON tblinvoices.id = racuni.pid
does not help, almost same result:
Before removing:
~~~~~~~~~~~~~~
2 rows in set (5 min 45.83 sec)
~~~~~~~~~~~~~~
After removing:
~~~~~~~~~~~~~~
2 rows in set (5 min 47.29 sec)
~~~~~~~~~~~~~~
Main issue is in line:
Code:
WHERE NOT EXISTS (SELECT * FROM racuni WHERE racuni.pid = tblinvoices.id)
when I remove this, query is executed very fast:
~~~~~~~~~~~~~~
17729 rows in set (0.72 sec)
~~~~~~~~~~~~~~
but then query return all rows, and I need only rows where "racuni.pid" are not same as "tblinvoices.id"
Thanks,
Miron J.