Revert "Optimize session.write from three to one sql-statement"

This reverts commit 578263e87f5f523cf2a7568b84499d0cd90cd58d.