Обсуждение: SELECT ... EXCEPT SELECT ... takes too long! Why?

Поиск
Список
Период
Сортировка

SELECT ... EXCEPT SELECT ... takes too long! Why?

От
Michael Andreasen
Дата:
I have a table;

create table product ( prod varchar(10) description varchar(40));

This is the master table. I also have serval other tables the same
(varchar(10), varchar(40)) and want to merge the rows from these tables
into the master one, only where rows don't already exist in the master
table.

I am doing this as follows;

insert into product
select prod, description from product_copy1 except
select prod, description from product;

This does work, but it takes FOREVER to perform. I have about 10,000
rows in each table and it is taking 20 mins. On the same System I can do
4,000,000 row inserts in 6 minutes, so this to slow.

Any help?