On Sat, 2005-06-11 at 12:32 -0500, Puneet Kishor wrote: > tbl1(a INTEGER PRIMARY KEY, b VARCHAR(200) UNIQUE) with 200k+ records > tbl2(a INTEGER PRIMARY KEY, b VARCHAR(200) UNIQUE) with a few k records >
> SELECT * > FROM ((SELECT * FROM tbl1) UNION (SELECT * FROM tbl2)) > WHERE b = 'foo' > > or > > SELECT * FROM tbl1 WHERE b = 'foo' > UNION > SELECT * FROM tbl1 WHERE b = 'foo' > The second form will be faster because of the index on column b. (Whenever you use the UNIQUE keyword in a column declaration, an index is created on that column automatically.) It will be faster still if you use UNION ALL instead of UNION. -- D. Richard Hipp <[EMAIL PROTECTED]>