Inserting 400 Million rows
I have a table table 1 and have the need to run the following to create the contents of table 2.
insert into t2 select a.col1, a.col2, b.col1, b.col2 from t1 a, t1 b
Table 1
col1 col2
a 1
b 2
c 3
would result in
table 2
col1 col2 col3 col4
a 1 a 1
a 1 b 2
a 1 c 3
b 2 a 1
b 2 b 2
b 2 c 3
.... etc
The problem is my table 1 has 20,000 rows in it and the resulting table has 20k x 20k rows ... and it takes FOREVER .. if it finishes.
What would be the best way to tackle this for time efficiency ???