How can I improve query performance for 200+ million records
I would write your exists
query like this:
SELECT stt.sgtin
FROM sgtins_tmp_table stt
WHERE EXISTS (SELECT 1
FROM sgtins s
WHERE s.client_id = 4 AND
s.sgtin = stt.sgtin
);
For this query, you want an index on sgtins(sgtin, client_id)
.