Subject Re: Keeping count of child records in master record
Author ainpoissee
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@...> wrote:

Thanks Svein and Philip,

> I'm uncertain whether this is safe or not, my guess is that it
depends upon transaction isolation. Another thing is that I guess
chances increase for concurrency issues, no two transactions can
insert records into TAB_Detail for the same TAB_Master.UID simultaneously.

Hmm, the general usage pattern is that only one user inserts to the
given master at time... but there might be exceptions. Transactions
are really short too, so I think that deadlocks would be extremly rare.


> Regardless of whether it is or can be made safe, I do not understand
the point of having such a column. Whenever you want to know whether
detail records exists or not, you can just issue:
>
> Select ...,

Thats exactly what I want to get rid of :)
It's a system which lazy loads detail records and in case there is no
detail records it hurts perfomance to issue those selects which return
empty result set. So the idea is to know beforehand do I actually need
to ask for detail records. Actually, just a boolean flag would do, but
record count would allow to allocate memory for detail records before
issuing the select to retrive them... and I think that boolean flag in
master record wouldn't be any safer than count, would it?


TIA
ain