tags:

views:

24

answers:

1

The following very simple snippet of SQL is failing:

UPDATE smalltable,bigtable
SET smalltable.ssn=bigtable.ssn
WHERE smalltable.last = bigtable.last && smalltable.first = bigtable.first;

bigtable has 16,000 records -- not really all that big for SQL. smalltable has about 300. For some reason this statement is timing out (> 30 seconds). Why? It seems very simple, and the data isn't hard to work with: not a lot of repeats, short fields (VARCHAR(20)), etc.

Am I doing something wrong? I'm just trying to update the records in smalltable with a simple (or so I thought) lookup in bigtable.

Edit: Very possibly relevant: smalltable is a LOCAL INFILE.

+4  A: 

Do you have indexes on:

smalltable.last, bigtable.last, smalltable.first, bigtable.first
RedFilter
Doh! Nuked my answer; this one's better. +1.
Billy ONeal
It wasn't my database, so I figured it was already set up with indexes, at least on the important tables like bigtable. No, it wasn't! Now MySQL reports that it took 0.000 seconds.
Charles