I have temporary memory tables A and B. each contain 1 column of integer values
I need to find all values which are in A but not in B.
The problem is that its very slow due to the fact (I think) that memory tables use hash and not ordered keys.
How can I perform it efficiently? Currently I’m using
SELECT val FROM tableA WHERE val NOT IN (SELECT val FROM tableB)
The definition of each table :
CREATE TABLE tableA (val INT, PRIMARY KEY USING HASH (val)) ENGINE = MEMORY;
some additional testing on 250K rows reveals that there’s not much between them:
full testing script: