Hi, Vladislav! On Jun 08, Vladislav Vaintroub wrote:
------------------------------------------------------------ revno: 3426 revision-id: wlad@montyprogram.com-20120608000841-ieo4vumio11pc8p9 parent: wlad@montyprogram.com-20120530182054-g7sll9u4gsitvgqe fixes bug(s): https://launchpad.net/bugs/1008334 committer: Vladislav Vaintroub <wlad@montyprogram.com> branch nick: 5.5 timestamp: Fri 2012-06-08 02:08:41 +0200 message: LP1008334 : Speedup specific datetime queries that got slower with introduction of microseconds
- Item::get_seconds() now skips decimal arithmetic, if decimals is 0. This significantly speeds up from_unixtime() if no fractional part is passed. - replace sprintfs used to format temporal values by hand-coded formatting
Looks ok. Would be good to mention the ~25% speedup in the comment above fmt_number. Like "Gives 25% speedup when converting temporal values to strings, as compared to sprintf". So that one wouldn't need to dig up bzr history every time.
=== modified file 'sql/item.cc' --- a/sql/item.cc 2012-05-21 18:54:41 +0000 +++ b/sql/item.cc 2012-06-08 00:08:41 +0000 @@ -1265,7 +1265,7 @@
bool Item::get_seconds(ulonglong *sec, ulong *sec_part) { - if (result_type() == INT_RESULT) + if (decimals == 0 || result_type() == INT_RESULT)
I'd expect that checking for decimals==0 alone should be enough. Could you try to run the test suite with the DBUG_ASSERT(result_type() != INT_RESULT || decimals == 0); please?
{ // optimize for an important special case longlong val= val_int(); bool neg= val < 0 && !unsigned_flag;
Regards, Sergei