A way to store date and time in postgresql ruby on rails -


which way of storing date , time provide quickest search data segments if plan search separately each? store in datetime type, maybe more pragmatically store in separate columns(e.g. date , time database types) purpose?

i haven't run benchmarks see need saving them different columns if you're planning on doing massive - , mean massive - queries on date alone.

timestamp (with time zone) 8 bytes  both date , time, time zone date                       4 bytes  date (no time of day) time (without time zone)   8 bytes  time of day (no date) time (with time zone)      12 bytes times of day only, time zone    

so if store them separately, takes @ least more +4bytes, or +8 if keep time zone on time field.

if you're going have massive number of rows query, you'll querying date might make sense, otherwise don't think (in fact might still make no sense since massive number of rows use more unnecessary space possibly offsetting perceived advantage).

i have used integer fields representing dates (up 'till months - e.g. 201704 index), because records reflecting unique monthly records , made sense, there's no date format reflecting year+month, otherwise pg quite optimised handle date timestamp situations.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -