"Timo Sirainen" <t...@iki.fi> wrote on 14.9.2010 19:24:14:
>On Tue, 2010-09-14 at 19:08 +0200, Miha Vrhovnik wrote: >> When removing/receiving new message and same in case of doveadm recalc. >> SELECT with key.. >> if not found >> INSERT >> else >> UPDATE > >I don't think this kind of code exists anywhere? I was being hypothetical. >The actual row updating code works with INSERT INTO .. ON DUPLICATE KEY >UPDATE .. with MySQL, and with INSERT+trigger with PostgreSQL. > >> unless I'm missing something upper one could be optimized to >> UPDATE >> if changed rows < 1 then >> INSERT >> >> which wouldn't require the SELECT and would also spare the trigger when >> using postresql. > >The trigger is there to avoid race conditions: > >1) two processes try to add the row at the same time >2) one process tries to update the row when another had just deleted it It seems that I missed the race conditions. Have decided that it would be best to give the Dovecot dedicated table and then add DELETE trigger and modify insert/update one to also update the values in my table. Regards, Miha -- It's time to get rid of your current e-mail client ... ... and start using si.Mail. It's small & free. ( http://www.simail.si/ )