MySQL Forums
Forum List  »  Performance

Re: What is faster: from_unixtime() or unix_timestamp()?
Posted by: Felix Geerinckx
Date: October 08, 2005 10:36AM

Dmitry Katsubo wrote:

> 1) Pass a timestamp as number:
> select case when from_unixtime(1128719129) > now() then 1 else 0 end;
>
> 2) Perform a query:
> select unix_timestamp();
> and then compare with timestamp in the high-level application
>
> 3) Pass a timestamp as a string:
> select case when '2005-10-08 00:10:10' > now() then 1 else 0 end;
>
> I guess, the first one should be faster, as aviods multiple strings parsing?

Don't guess, but find out:

mysql> select benchmark(1000000, from_unixtime(1128719129) > now());
+--------------------------------------------------------+
| benchmark(1000000, from_unixtime(1128719129) > now()) |
+--------------------------------------------------------+
| 0 |
+--------------------------------------------------------+
1 row in set (2.45 sec)

mysql> select benchmark(1000000, '2005-10-08 00:10:10' > now());
+------------------------------------------------------+
| benchmark(1000000, '2005-10-08 00:10:10' > now()) |
+------------------------------------------------------+
| 0 |
+------------------------------------------------------+
1 row in set (0.08 sec)

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: What is faster: from_unixtime() or unix_timestamp()?
1868
October 08, 2005 10:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.