[odb-users] Re: Explain please the essence of the strange update_statement

Boris Kolpackov boris at codesynthesis.com
Fri Sep 9 09:54:00 EDT 2011

Hi Viacheslav,

Вячеслав Спиридонов <art at it-gen.net> writes:

> const char* const access::object_traits< ::CDboPlayer >::update_statement =
> "UPDATE `players` SET "
> "`Id` = ?,"
> "`LastAuth` = ?,"
> "`Name` = ?"
> " WHERE `Id` = ?";
> What is the point in UPDATE to overwrite PRIMARY KEY?

The main reason is to reuse some data structures between the UPDATE
and INSERT statements. Our thinking is that it doesn't hurt since
we always send the same value as is already in the database and
the database implementation is smart enough to detect this and not
do anything expensive.

> It seems to me that this could a negatively affect to the group 
> UPDATE. Now I am faced with a situation when the update 50K of
> objects CDboPlayer work out very slowly (about a few minutes.)
> The operation was carried out a single-stream, any locks are 
> excluded.

Hm, are you saying that by just including the primary key in
UPDATE, it slows MySQL down significantly? Can you show some
numbers that substantiate this (e.g., a how long it takes to
run UPDATE with primary key included (but the same value as
already in the database) vs the same statement without the
primary key)? If this is true then we will definitely have
to fix this.


More information about the odb-users mailing list