Subject Re: [firebird-support] union performance
Author Kjell Rilbe
Ann W. Harrison wrote:
>
> Milan Babuskov wrote:
> > Sergio H. Gonzalez wrote:
> >> select ID,descripcion from STOCK
> >> union ALL
> >> select id,razon_social from proveedores
> >> order by 1
> >>
> >> PLAN (STOCK NATURAL)
> >> PLAN (PROVEEDORES NATURAL)
> >
> > NATURAL means that no index is used. Do you have index on stock.ID or
> > preoveedores.ID ?
> >
>
> How could firebird use an index with no WHERE clause and a UNION
> that keeps it from walking an index?

Well, if there are indexes on STOCK.ID and proveedores.id, these indexes
*could* be used to sort each stream and do a sorted merge to produce the
union stream. I assume it would be faster than doing a natural, append
one stream to the other and then sort the whole thing, which I assume
Firebird is doing according to the quoted plan.

But Firebird doesn't do sorted merges I guess?

Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64