[CLUG-tech] SQL Query Question

Erhard Eiselen eis at tad.co.za
Wed Dec 19 08:35:57 SAST 2007


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);
> >>

<snip>

Although this type of select will always work, it is notoriously slow.
I am not sure what DB your are using, but DB engines like Informix
and Oracle normally have functionality where you can trace 
what the query engine does and then adjust your query/indexes where necessary.
I now for Informix it is "set explain on" and then you run your query
and it outputs a logfile you can "vi".


E-mail is not necessarily secure or error free as information could arrive
late or contain viruses or could be incomplete, intercepted, corrupted, lost
or destroyed. It is the responsibility of the named recipient(s) to ensure
that E-mails are virus free.


More information about the clug-tech mailing list