Not in or Not exist Query Very Slow for Large Data Sybase
<p>I have a table A which is having around 50000 records and a table B which is having 50000 records as well.
sample data:</p>

<pre><code>A                   B
1                   1      
2                   2
3                   null
4                   null
</code></pre>

<p>I want to find records 3, 4 which are present in Table A but not in Table B.
I am using </p>

<pre><code>select id from A where id NOT IN(select id from B)
</code></pre>

<p>I have also tried NOT Exist, but as the records are very large in number, it still takes a lot of time.</p>

<pre><code> select id from A where NOT Exists(select id from B and B.id = A.id)
</code></pre>

<p>Left Outer Join cant be used to find the missing records as the id is not present in Table B.</p>

<p>Is there any way to make the Query Work Faster in Sybase itself?
Or Shifting the database to MongoDB is the solution?</p>