Comments on: What SYSDATE is it? http://www.xaprb.com/blog/2011/10/11/what-sysdate-is-it/ Stay curious! Thu, 02 May 2013 12:36:53 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Sheeri http://www.xaprb.com/blog/2011/10/11/what-sysdate-is-it/#comment-19690 Sheeri Tue, 11 Oct 2011 18:39:16 +0000 http://www.xaprb.com/blog/?p=2496#comment-19690 Baron, NOW() is not ANSI standard SQL, I do not believe it is in Oracle. CURRENT_TIMESTAMP() is the standard SQL term. (In fact, SYSDATE() isn’t in the standard either)…..that’s in the blog post, but I figured it might be interesting to folks even if they don’t click the link.

]]>
By: Sheeri http://www.xaprb.com/blog/2011/10/11/what-sysdate-is-it/#comment-19689 Sheeri Tue, 11 Oct 2011 18:34:25 +0000 http://www.xaprb.com/blog/?p=2496#comment-19689 NOW() is deterministic with replication because NOW() is an alias to CURRENT_TIMESTAMP(). SYSDATE() is not, and you can use that functionality to your advantage, much like pt-query-checksum take .

For example, I could do:

SELECT SYSDATE(), SLEEP(30), SYSDATE(); and SYSDATE would show the results. That’s a trivial example but it makes the point.

I’ve also seen it as a way to store a heartbeat with its corresponding lag – if you have a heartbeat table and insert NOW(), SYSDATE() into 2 time fields you can take the difference and see how far behind lag was at any given time.

SYSDATE() is the system date, and it uses the timezone of the server, so I’ve seen this be problematic, too (e.g. a machine in Eastern US time replicates to a machine in Pacific US time and uses SYSDATE() instead of CURRENT_TIMESTAMP() or NOW() and all the times are 3 hours different).

http://www.pythian.com/news/1295/does-anybody-really-know-what-time-it-is/

Times and timezones are VERY important. For instance, if you change the time on your server, some of your time values in MySQL change and others do not, depending on whether they are TIMESTAMP or DATETIME values.

Personally I’ve found that if folks are using SYSDATE() it’s because they’re coming from an Oracle environment, and they do plenty of other things to actually worry about (such as index every column and expect merge indexing to work the same as in Oracle).

]]>
By: TehShrike http://www.xaprb.com/blog/2011/10/11/what-sysdate-is-it/#comment-19688 TehShrike Tue, 11 Oct 2011 17:42:10 +0000 http://www.xaprb.com/blog/?p=2496#comment-19688 I appreciate that there are two different functions for getting datetimes, though I almost always want the NOW() functionality in my queries.

I’ve only ever used SYSDATE() when testing something.

]]>
By: Shlomi Noach http://www.xaprb.com/blog/2011/10/11/what-sysdate-is-it/#comment-19687 Shlomi Noach Tue, 11 Oct 2011 16:17:13 +0000 http://www.xaprb.com/blog/?p=2496#comment-19687 Heh,
Expect some queries involving this very issue on my coming talk on Percona Live, London.

]]>