[CLUG-tech] SQL Query Question

Chris Meistre meistrch at intekom.co.za
Wed Dec 19 08:24:59 SAST 2007


Michael Wood wrote:
> On Tue, Dec 18, 2007 at 10:49:14PM +0200, Chris Meistre wrote:
>> Hi there,
>>
>> I have a table with more than 900,000 entries in.
>>
>> table1
>> url
>> text
>>
>> I also have another table that I put values about table1's info.
>>
>> table2
>> url
>> moretext
>>
>> For various reasons I cannot put the data together in one table, and 
>> need to use 2 tables.   Once I do something to the values I put them in 
>> table2.  And then I don't touch it again.
>>
>> To select the elements I haven't scanned yet I use the following query:
>>
>> select * from table1 where url not in (select url from table2);
>>
>> This gives me all the rows in table1 that haven't been put into table2.  
>> Now, this works but takes ages to run.   Can anyone help me with a 
>> better, quicker query?
> 
> Try this:
> 
> SELECT a.url, a.txt FROM table1 AS a LEFT JOIN table2 AS b ON a.url = b.url WHERE b.url IS NULL;
> 
I tried this, with not too much speed improvement.


More information about the clug-tech mailing list