xocolatl,

Hey people.

Do you use ±infinity in your dates and timestamps? What is your use case? What would you do instead if they weren't available?

Please boost for reach.

tshirtman,
@tshirtman@mas.to avatar

@xocolatl as a negative data point, i never used it, didn’t even know about it.

xocolatl,

@tshirtman
What do you use instead?

tshirtman,
@tshirtman@mas.to avatar

@xocolatl i don’t think i’ve ever felt a need for it, the case described earlier (unknown end date) seems to be more appropriately covered by NULL, more philosophically, i don’t think anything can be described as "infinite" in the time dimension, at best you don’t know when things are going to end, but invariably they will.

regarding -infinite, i guess if i was describing things in the early universe, i would use 0 as the starting point, (assuming time itself even makes sense there).

xocolatl,

@tshirtman
What if you are recording deaths? Does a null mean they are still alive, or does it mean you don’t know when they died?

tshirtman,
@tshirtman@mas.to avatar

@xocolatl yes, the date of my death is unknown, i wish i could say it’s infinitely in the future, but that wouldn’t match general observations of how the world work. Until that event has happened, its date is unknown, it might indeed even be unknown to anyone for some time after it has happened, so you can’t really distinguish the two.

If someone can’t possibly be alive anymore, but we don’t know their death date (historical person), maybe it would make sense to indicate an interval for that.

xocolatl,

@tshirtman
I wasn’t talking about your death, I am talking about recording deaths in general. How do you query for people who are known to be alive, or for people whose continued existence is unknown, if you use null for both?

tshirtman,
@tshirtman@mas.to avatar

@xocolatl my death was just an example.

I don’t think you can tell someone is alive for sure unless you are in front of them or have some real time reporting system, so i don’t think in a DB it’s a different value. For all you know, people with a NULL value are not dead (so, alive).

Sorry if this comes of as obnoxious, but i don’t think there is a meaningful distinction here.

l_avrot,

@tshirtman @xocolatl
My Dad is into genealogy and when he has a record for a guy born in the 17th century with a NULL date for its death date, he does not assume the guy is still alive (except maybe if he's named Lestat).

You can't give meaning to the NULL value, that's a common misconception that can lead to real production disasters.

tshirtman,
@tshirtman@mas.to avatar

@l_avrot @xocolatl but +infinity wouldn't cut it either, there, right? Of course you could put something like birthday+100 to be quite safe as a bound, but it's obviously a wild guess, and i believe i would rather a value thau says "we don't know", which is what i believe NULL is for. I didn't mean to say that NULL means alive, in case that wasn't clear, but i believe you need more logic to decide what to do with the NULL value, based on context.

It only leads to disaster if misinterpreted.

l_avrot,

@xocolatl

I suggest using it when you have a table of renting equipment with a range for the renting period. Yous can use infinity as an end date as long as the good is rented.
(I also suggest partitioning to be able to archive old partitions and reduce the table scans on live data only)

tshirtman,
@tshirtman@mas.to avatar

@l_avrot @xocolatl wouldn’t Null (indicating unknown) be more appropriate? You just don’t know that information. Unless you are going out of your way to avoid using Null as much as possible.

truls46,
@truls46@mastodon.social avatar

@tshirtman

If the column represents e.g. an expiration date (where NULL means "does not expire") you would need something like:

WHERE col <= some_constant OR col IS NULL

which typically won't use an index.

When using +infinity the OR .. IS NULL is no longer necessary which then opens up the possibility to use an index.

tshirtman,
@tshirtman@mas.to avatar

@truls46 ok, for this case, where indeed you want to express "does not expire" (like, a permission, or something immaterial of the kind), i do think it make sense.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • postgres
  • GTA5RPClips
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • tacticalgear
  • cubers
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • InstantRegret
  • JUstTest
  • everett
  • Durango
  • cisconetworking
  • khanakhh
  • ethstaker
  • tester
  • anitta
  • Leos
  • normalnudes
  • modclub
  • megavids
  • provamag3
  • lostlight
  • All magazines