Please, excuse me if I missed this in the new DB Layer code. I have just browsed the code from CVS, but it looks to me that a particular feature of MySQL ODKU clausule is not used. ie. field = VALUES(field)
INSERT INTO table (pkey, field_a, field_b) VALUES (1, 2, 3)
ON DUPLICATE KEY UPDATE
field_a = VALUES(field_a),
field_b = VALUES(field_b);
With this syntax it is not necessary to duplicate INSERT values for the ODKU clausule. This may be specially important when big TEXT/BLOB field literals/expressions are invoved, such as db_merge() usage in cache_set().
It has impact on the size of the SQL statemente itself, max_allowed_packet, ...
Comments
Comment #1
Crell commentedHm, interesting. I wasn't aware of that syntax. So you're saying that cache_set, for instance, would become:
That does seem like a nice optimization. We can probably use that for the default case (just fields()) and for updateExcept(), but not for update(). Can you roll a patch so we can see if it works?
Comment #2
markus_petrux commentedNot exactly. Note that it is not needed to update the key. ie. this is not needed:
cid=values(cid)So the statement would look something like this:
Rolling a patch created by looking at the code. It is not tested, but I think it may work, or at least you can get the idea. :)
Comment #3
markus_petrux commentedRerolled.
$update_fieldsis not really needed in execute() method.Comment #4
markus_petrux commentedI'm very sorry I was not enterily familiar with all merge related methods and I figured I missed the fact that the caller can explicitly specify which fields need to be updated.
Patch re-rolled.
Comment #5
Crell commented#4 totally doesn't apply at all. :-( I suspect it's because of the whitespace changes that were fixed a week ago. Can you reroll please?
On visual inspection it looks reasonable (and small, which I like), although the comments need a spellcheck and some language cleanup.
Comment #6
markus_petrux commentedThere you go. This time I believe I have used correct english and technical words. :-/
I wasn't sure whether to include a link to the MySQL manual for this particular syntax. Here's the function VALUES(col_name), if that helps:
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#func...
Comment #7
dries commentedLooks like a nice optimization, but I'd like to see Crell approve it first.
Comment #8
Crell commentedLooks good to me, and all database tests pass. Sadly there are Windows linebreaks in #6. :-( Attached patch is identical but removes them. Please don't credit me.
This should really help with things like cache sets.
Comment #9
dries commentedCommitted to CVS HEAD. Thanks! Welcome back, markus_petrux. :)
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.