Continuing our discussion of #PostgreSQL time types, what about the much-maligned TIMESTAMP type, without TIME ZONE? 1/n
TIMESTAMP and TIMESTAMP WITH TIME ZONE have exactly the same binary representation. TIMESTAMP WITH TIME ZONE means "this timestamp is known to be in UTC." 2/n
TIMESTAMP-no-TZ means "no idea what time zone this particular date and time are in, hope you do." 3/n
The general advice, which is good advice, is to always use TIMESTAMP WITH TIME ZONE, because then the value is fully specified: It is always a precise moment in time, and you need no further information to interpret it. 4/n
So, when might we use plain ol' TIMESTAMP? There are some possibiltiies: 5/n
-- You are receiving date/time values but you don't know at the time of ingestion what time zone they are, and don't want to take the time to convert them right then. 6/n
-- Times that are "always local time." For example, if every one of your stores will close at 4pm on 12/24, and reopen at 10am on 12/26, but they're in different time zones, that might be one way of storing them. 7/n
-- Similarly, calendar systems that want to store an event as "always happens on local time" might use TIMESTAMP-no-TZ as a data type for that. 8/n
Note, though, that these are all edge cases, and require that you have some external source of what time zone the timestamp is in for them to be useful. Because of that, you almost always want TIMESTAMP WITH TIME ZONE. 9/end

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Christophe Pettus

Christophe Pettus Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Xof

4 May 21
Let's talk a bit more about setting work_mem in #PostgreSQL. 1/n
The basic rule is "as high as required, and no higher." But how high is required? 2/n
A lot of tools and websites will give you formulae, usually based on some combination of system memory and number of connection. These aren't *wrong* exactly, but... 3/n
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(