Subject RE: [Firebird-Architect] RFC: Proposal for the implementation of Temporary Tables.
Author Samofatov, Nickolay
Hi, Ann!

> >I would simply add ATTACHMENT_ID system column (probably with
> >appropriate index) to tables declared as temporary and
> taught optimizer
> >to filter out rows which should not be visible by current attachment.
>
> The more I think about it, the less I understand it. If you
> have a temporary table with a primary key, is there an index for each
> attachment or a single index for the table?

Single index for the whole table. When any index is defined for temp
table engine should add ATTACHMENT_ID segment to it automagically.

BTW, note the spec for FK constraints for temp tables:
---
5) The referenced table shall be a base table.
Case:
a) If the referencing table is a persistent base table, then the
referenced table shall be a persistent base
table.
b) If the referencing table is a global temporary table, then the
referenced table shall be a global temporary
table.
---

This spec makes FK implementation trivial if we have ATTACHMENT_ID
column. Both UQ index and partner index are going to have ATTACHMENT_ID
column and linking them does not require any special handling.

> Are you storing data for all users on the same pages?

Yes.

> Ann

Nickolay