Subject Re: [firebird-support] Great variance in speed of an INSERT INTO ... SELECT
Author Josef Kokeš
Hi Ann,

> The WHERE 1 = 1 is unnecessary, but doen't do any harm. There maybe
> databases that require a WHERE clause, but Firebird doesn't. But that's not
> the problem.

I know. But I wanted to emphasise that there are no limitations on the
rows, so no index should come into play.

> The normal cause of wild variations in the performance of queries is garbage
> collection. For example, if you did this query twice, deleting all rows in
> backuptable, then resetting the generator backupgen to 1, the second run
> would have to remove all the old rows and deleted stubs and clean up the
> indexes (assuming that source_key is actually a unique key).

Garbage collection doesn't seem to play any significant part. I even
deleted the whole backup table, performed the backup/restore cycle, and
still got long times. What *did* help was limiting the SELECT from
sourcetable to "significant records", some 6000 of them (a reduction of
two orders of magnitude). But it still seems strange that Firebird would
choke on INSERTs, even in what I perceive to be the ideal condictions to
the server.

Pepak