Jan Wieck JanWieck
Sun Jul 30 18:48:07 PDT 2006
On 7/31/2006 8:05 AM, Sean Kirkpatrick wrote:
>> Supposing we had a single column primary key, it ought to be 
>> possible for
>> the slon to recognize:
>> 
>>  - I'm issuing "delete from foo where id = x;"
>> 
>>  - Hmm.  The next statement is "delete from foo where id = y;"
>> 
>>  - That could be folded into the statement:
>>      delete from foo where id in (x, y);
>> 
>>  - If we keep deferring, we might discover that the next statement is
>>      delete from foo where id = z, which could turn that into...
>> 
>>      delete from foo where id in (x,y,z);
>  
> This sounds like a viable way to reduce the number of statements to propagate.

It would only work reliable for immediately contiguous delete statements 
that are not mixed with any other insert, update or delete and that fall 
into one and the same SYNC chunk. There are insert, update, delete 
sequences that could otherwise become impossible to replicate.

For a simple example, imagine an application does this, not necessarily 
in one transaction, but that all these statements belong to one sync chunk:

delete ... where id = 2;
insert ... (id) values (3);
delete ... where id = 3;
insert ... (id) values (2);

In this case you cannot group all deletes together. If you execute them 
before the inserts, you will end up with an unwanted (and wrong) id=3. 
If you try to do them after, you never get there because the insert with 
id=2 will cause a duplicate key. And you can't do it before and after or 
you end up without the required id=2.

Considering that deletes have the smallest footprint of all replicated 
operations, I don't think the effort necessary to find possible 
sequences of delete statements that can be grouped together without any 
risk is not worth it.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck at Yahoo.com #



More information about the Slony1-general mailing list