Delay the creation of the indexes.

Delay the creation of the indexes on the intermediate tables until the table is taken
out of copy mode.  If the ram node cache is large enough, that doesn't happen until
the tables are complete.  Building indexes in bulk is much faster than keeping
them updated one row at a time.

Something probably needs to be done about being in append mode, but "options" variable
is not visible at this part of the code and I can't test that mode, anyway.