Page 1 of 1

Query speed: replace into vs insert into ... select distinct

Posted: Sun Sep 01, 2002 4:30 am
by sunderwind
Can anyone tell me which of the following would generally be faster? I do not know what my client has done to optimize mysql. Their mysql is running on a Sun E450 with 4 sparc 450 and 4 gigs of ram.

from_id is an int and to_id is the primary key in the table.

replace into [table] (to_id) select from_id from ....
This result set could have as many as 300,000 rows.

or

insert into [table] (to_id) select distinct from_id from ....
This result set could has as many as 100,000 rows.

Posted: Sun Sep 01, 2002 10:14 am
by gotDNS
I suppose the bottom one would generally be faster, if you think about it, also because less result rows possible, too.

later on, -Brian