Subject | Re: Dirty read? |
---|---|
Author | johnsparrowuk |
Post date | 2004-06-04T19:42:18Z |
As an example, take the other thread on here about indexing a varchar
(300) field (or something of a similar size). It's too big to index -
no problem. Write a 'before insert' trigger that does something
like:
select count(*) from mytable where longtextval = new.longtextval
into :i;
if (i > 0) then
exception value_exists;
...except that it won't work like an index because it can't see
uncommitted values. (ok it would be slow and probably not a good
idea anyway, but you see my point).
I've got a similar problem in one of my apps, needing unique long
varchars. I hash the string value and store that in a non-unique
indexed integer column. Then a trigger uses the hash index, and if
it finds a match does a slow text search to confirm it's a unique-
violation.
But could fail on concurrent transactions.
If I could dirty-read this wouldn't be a problem. If dirty reading
is 'always bad' then how come indexes can do it?!?!? grin
Anyway, clever multi-gen solutions would be much appreciated! I
can't think of anything that doesn't use unique indexes (impossible
in this case because of the string length). Of course the hash isn't
guaranteed unique...
John
--- In firebird-support@yahoogroups.com, Jakub Hegenbart
<Kyosuke@s...> wrote:
(300) field (or something of a similar size). It's too big to index -
no problem. Write a 'before insert' trigger that does something
like:
select count(*) from mytable where longtextval = new.longtextval
into :i;
if (i > 0) then
exception value_exists;
...except that it won't work like an index because it can't see
uncommitted values. (ok it would be slow and probably not a good
idea anyway, but you see my point).
I've got a similar problem in one of my apps, needing unique long
varchars. I hash the string value and store that in a non-unique
indexed integer column. Then a trigger uses the hash index, and if
it finds a match does a slow text search to confirm it's a unique-
violation.
But could fail on concurrent transactions.
If I could dirty-read this wouldn't be a problem. If dirty reading
is 'always bad' then how come indexes can do it?!?!? grin
Anyway, clever multi-gen solutions would be much appreciated! I
can't think of anything that doesn't use unique indexes (impossible
in this case because of the string length). Of course the hash isn't
guaranteed unique...
John
--- In firebird-support@yahoogroups.com, Jakub Hegenbart
<Kyosuke@s...> wrote:
> johnsparrowuk napsal(a):don't
>
> >Is it possible to dirty-read uncommitted data in Firebird?? (I
> >think it is, but someone might prove me wrong!)in
> >
> >Why do I want to do this mad thing??? Well, it's sometimes useful
> >triggers etc, and it might help work around some inconsistenciesvisible
> >caused by the way unique indexes work - ie they can 'see' other
> >clashing uncommitted values, even though thouse changes arn't
> >any other way.(I
> >
> >Thanks,
> >
> >John
> >
> >
> Possible? Not at all...unless you hack the sources.
>
> To use MGA efficiently, one must change the way of thinking a bit.
> still consider myself a novice, too :) Is there really no otherway to
> solve it? It seems to me that in the last 20 years, people had few
> problems using MGA in IB/FB :)
>
> Jakub Hegenbart