Subject | Re: [firebird-support] Multi-database query |
---|---|
Author | Ann W. Harrison |
Post date | 2005-06-21T18:41:12Z |
Gary Benade wrote:
It has never supported a cross-database join. When the primary
language for the database was GDML, you could work around that with
nested loops like this:
READY 'noah:/usr/databases/ark.gdb' as ark;
READY 'sandiego:/user/database/zoo.gdb' as zoo;
FOR x IN zoo.animals
FOR y in ark.animals with x.species = y.species
printf ("Noah's %s is in cage %d\n",
y.common_name, x.cage);
END_FOR;
END_FOR;
You could do the same thing with SQL cursors - but most interfaces don't
support SQL cursors.
The reason for supporting nested loops but not joins is neither that the
developers of Firebird and InterBase were ignorant, or that they were
deliberately making the product difficult to use, but that the problems
of optimizing a cross database query are hard. Nested loops are easy -
the syntax determines the join order. Solving the multi-database
optimization problems was put off to the next version on five versions
of InterBase and Firebird that I've worked on.
Regards,
Ann
>InterBase has always - since version 1.0 - supported a two-phase commit.
> There have been references to Multi-Database Access, Automatic Two-Phase
> Commits and Distributed Two-Phase Commit Recovery since the interbase 6
> days. There must be something going on, although I can find no reference to
> it in any of my docs
>
It has never supported a cross-database join. When the primary
language for the database was GDML, you could work around that with
nested loops like this:
READY 'noah:/usr/databases/ark.gdb' as ark;
READY 'sandiego:/user/database/zoo.gdb' as zoo;
FOR x IN zoo.animals
FOR y in ark.animals with x.species = y.species
printf ("Noah's %s is in cage %d\n",
y.common_name, x.cage);
END_FOR;
END_FOR;
You could do the same thing with SQL cursors - but most interfaces don't
support SQL cursors.
The reason for supporting nested loops but not joins is neither that the
developers of Firebird and InterBase were ignorant, or that they were
deliberately making the product difficult to use, but that the problems
of optimizing a cross database query are hard. Nested loops are easy -
the syntax determines the join order. Solving the multi-database
optimization problems was put off to the next version on five versions
of InterBase and Firebird that I've worked on.
Regards,
Ann