Apologies if this has been asked before, searching for it yields too many results.
I've been eliminating NOT EXISTS in some code by LEFT JOINing tableX and using a WHERE TableX.JoinColumn IS NULL
Big gains, I'm pleased with that.
My next challenge is OR in a JOIN criteria, so...
SELECT id
FROM table1
LEFT JOIN table2
ON table1.keycolumn = table2.keycolumn
AND (table1.code1 = table2.code1 OR table1.text1 = table2.text1)
Performing 2 SELECT queries and UNIONing them to avoid the OR comes to mind,
The bigger picture is that I want to LEFT JOIN to this subquery to reproduce the NOT EXISTS functionality that performs so badly.
I'm eliminating records that match the crazy OR join.
This is a medical application, I can't change the tables, merely report on them.
Any ideas most appreciated.
Thank you
Have you tried using temp tables to break things down? Joining to your index-optimised temp table might speed things up.
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.