java - Best (performance-wise) way to store timestamp in mysql -


i have java application records timestamps events. problem faced there large volume, , having java calculate , format datetime costly performance. setup mysql field automatically use current_timestamp. had huge performance gain in app.

the big problem i've encountered half our users have mysql servers hosted elsewhere, , timezone settings different , may not changed.

i need find way generate timestamp on either side, in way that's not hit performance converted correct timezone, if needed.

i've considered using unix epoch instead, since doesn't need formatting when i'm inserting data, should less of performance problem.

is there better way?

quoting mysql manual:

mysql converts timestamp values current time zone utc storage, , utc current time zone retrieval. (...) [current] time zone can set on per-connection basis [with time_zone system variable].

i recommend sticking built-in timestamp type. time zone current session can set issuing (e.g. utc+2) set session time_zone = '+2:00';.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -