28

Regarding In PostgreSQL, why does an interval of '1 month' sometimes count as 30 days and sometimes count as 31 days?:

I didn't ask this question, but I found the close reasons confusing.

The question was initially closed as "Not suitable for this site" with a custom close reason:

I’m voting to close this question because it is not about "code" but instead asks why a perfectly reasonable implementation choice of a particular piece of software is unexpected to the asker. Such questions should instead be directed to the vendor of the software.

The question was then reopened and closed again with the reason "Opinion-based" with another comment:

@alex you are asking why Postgres date arithmetic works in a particular way. We cannot speak for why Postgres developers/architects made the choices they made. We can only express our guesses at why, which cannot be "correct" or "incorrect" as they are opinions. I've changed the close reason to "opinion based" to reflect this.

It's been left closed by other reviewers, all the same, for both reasons. I've searched around trying to understand these reasons:

Is asking for an explanation of some code on-topic?

"Explain X to me" questions: How to react?

How to handle "Explain how this ${code dump} works" questions

As far as I can tell, the question is about code, and it has a reproducible example with clear results that the asker finds confusing. Asking a "why" question is not necessarily off-topic, if it is specific enough. It is not a broad question. In fact, it's pretty much as narrow in focus as it can be. The entire architecture is not in question here or why it was made that way. Even the accepted answer is very fact based and doesn't involve developers' opinions. What am I missing? Is this just a subjective, what feels right, type of a situation?

If you don't know how PostgreSQL "interval" behaves, would that question and answer not help you?

8
  • 3
    It seems that the person who voted for closure misunderstood the question. They seem to have thought that the OP was trying to question the implementation and the reasons behind it instead of just asking for clarification of what is actually happening during the code execution.
    – S. Dre
    Commented May 2, 2022 at 6:43
  • 14
    This smells like people trying to find reasons to close a question rather than trying to reason why to keep them open. Because indeed it was quite easy to reason why to keep this open. I hope the close voters get a friendly reminder from a mod to use their close votes wisely rather than just grinding their pool empty.
    – Gimby
    Commented May 2, 2022 at 8:14
  • 3
    @Gimby in this case the close voter is a mod Commented May 2, 2022 at 8:25
  • 3
    @BillTürstandswithUkraine Sigh. We just can't have nice things.
    – Gimby
    Commented May 2, 2022 at 9:35
  • 2
    Is it just me or does the original question sound ridiculous? Eh, it's because not all months are 30 days, you learn that much at school! Why are people so keen to keep this question open, it's terribly basic almost to the point of pointless.
    – user692942
    Commented May 2, 2022 at 15:40
  • 1
    @user692942 As I was rather forcefully reminded in comments on this answer, "sounds ridiculous" (I used the word "lame") is not a valid close reason. Commented May 3, 2022 at 4:18
  • 1
    @Gimby This happens because the site ownership kept taking away or switching around perfectly good close reasons, in line with the original vision, as part of an effort to transform the site into something it is not, cannot be, and should not try to be. Meanwhile zero support is provided for basic things that would actually help, such as chat discoverability. Commented May 3, 2022 at 13:39
  • 1
    @Gimby Re. "This smells like people trying to find reasons to close a question rather than trying to reason why to keep them open", exactly right, and even digging in when it was blindingly obvious that the question wasn't asking one of those "why" questions with an unknowable answer.
    – skomisa
    Commented May 5, 2022 at 1:54

3 Answers 3

25

I fully agree with your assessment of the question. This was a clear (not to mention an uncharacteristically good formatting, descriptive title, and lack of extraneous noise), on-topic question about a particular behavior of a PostgreSQL operator with interval data type.

And indeed, this is explicitly explained in section 9.32 of the PostgreSQL official docs, so no insight into minds of the developers was needed to answer the question. Neither could such a question possibly lead to opinion-based answers, as this is a question about defined behavior.

Granted, that was a rather basic misunderstanding, but it alone does not make it off topic on Stack Overflow either. It could make it not useful to future visitors, but it got quite a decent answer, as well as is worded in a way that would be searchable for others with a similar situation (example query).

10
  • 3
    Shame we no longer have a RTFM reason for closures.
    – user692942
    Commented May 2, 2022 at 15:37
  • 2
    @user692942 SO is supposed to be the manual.
    – Alex
    Commented May 2, 2022 at 17:25
  • 7
    @Alex and there’s the problem, it isn’t. That’s what books and official documentation are for, it just takes effort. If you're still struggling after that, then SO is there to help.
    – user692942
    Commented May 2, 2022 at 17:52
  • 9
    If you were to remove all questions and answers about something that happens to be documented somewhere in some manual, you wouldn't be left with much content here.
    – Alex
    Commented May 2, 2022 at 18:00
  • 3
    There is no substitute for official documentation, regardless of how many useless answers are posted on this site for cheap rep gain.
    – user692942
    Commented May 3, 2022 at 10:46
  • 6
    @Alex disagree in the strongest possible terms, with a meta citation. "you wouldn't be left with much content here" Stack Overflow would be orders of magnitude more useful if it had much less "content" (which is overwhelmingly people looking for debugging help with very personal situations that are just special cases of something simple that they should have been able to find themselves if they applied standard research and debugging techniques). All of that junk gets in the way when I try to find duplicate closure targets. Commented May 3, 2022 at 13:29
  • 6
    @Alex - No; It’s not. We are absolutely not a manual. Commented May 4, 2022 at 3:36
  • 8
    @Karl: Just to offer an opinion to the contrary; just because some answer is inferable from a piece of documentation does not mean that a question+answer is redundant. It might add context, special circumstances, a reproducible example. Even in this concrete instance, just locating the "magic sentence" IMHO is a service SO provides. I have more than once searched on SO for stuff that man bash would have answered, just orders of magnitude slower.
    – ojdo
    Commented May 4, 2022 at 9:29
  • As compassionatecoding.com is trying to teach us, RTFM is not a great way to welcome newbies to the profession. This matters for this question because someone who asks a fairly basic question about PostgreSQL functionality is more likely than an average poster might be to know where to find the documentation or (more likely) where to look in the documentation for the right results. With a polite response that links to the docs, SO can encourage the poster, and also show them where they can find PostgreSQL info for themselves next time.
    – chris
    Commented May 4, 2022 at 17:45
  • 2
    @SecurityHound Saying that we are a manual was not the right wording, you are right. What I meant to convey is that SO is a layer on top of other documentation. We shouldn't think that information that exists in a documentation somewhere should not be reflected also here where need be, SO adds extra and valuable content to the existing documentation.
    – Alex
    Commented May 5, 2022 at 5:57
2

The original question is clearly opinion-based. A very similar question to yours was asked here on Meta several years ago and received this answer from Eric Lippert

Is asking “why” on language specs still considered as “primary opinion-based” if it can have official answers?

Long-time readers of my blog or my answers on SO know that this whole area is a peeve of mine.

The fundamental problem with the "why" question is not that the answer is an opinion. The fundamental problem is that it is impossible to know what will satisfy the person asking the question because the question is vague.

The question is often phrased "why does program X produce behaviour Y?" The answer given is often "because section Z of the specification says that's the right behaviour". Does that answer satisfy the original poster? It seems unsatisfying; it seems like it answers a "why" question with "just because". It seems like the natural next question to ask is "but why does the spec say that?" Because that's what the spec authors wrote. Well why did they write that? Because that's what they thought the best way to define the language was. Why did they think that?

...

This explanation rings true for the question you highlight too. The question is concise, well defined and well written, but the answer to "why does an interval of '1 month' sometimes count as 30 days and sometimes count as 31 days?" is "because the spec says so." This isn't a particularly useful answer for anybody.

The obvious follow up question is "Why does the spec say that?", then the explanation starts to get hairier.

As Eric says in his Meta answer, such "why" questions are better rephrased.

The new question title from Braiam's recent edit is on-topic and not opinion based:

How are months intervals internally calculated in Postgres?

14
  • 2
    Don't be so dogmatic. Speaking only for [java] on SO, the language designers regularly post answers to "Why does Java...?" questions. Here are a couple of examples: Why does List.of() in Java not return a typed immutable list? and In Java 16+, Is there any reason why a class sealed to a single child class can't access methods from that child?, but there are many more. If your question is a good one, you are inviting authoritative and illuminating answers by asking "Why..." questions about Java!
    – skomisa
    Commented May 4, 2022 at 6:00
  • 2
    @skomisa and while that's good an all, it cannot be used as general rule, these are exceptions. I don't want to do sweeping rules based on exceptional circumstances.
    – Braiam
    Commented May 4, 2022 at 10:19
  • Some design decisions are more arbitrary than others, and some non-arbitrary justifications are more obvious than others. Commented May 4, 2022 at 16:00
  • The problem with explaining internal calculations is that this requires reading PostgreSQL source code to know you are correct. It also requires explaining things like why 2100 will not be a leap year. The OP posted a simple question and probably wants a simple answer, something like, "This happens because PostgreSQL calculates '1 month' as the number of days from the start date to the date in the next month that has the same day component." You would also need to explain what happens when the calculated day doesn't exist - for example, one month after Jan 31 is not Feb 31. Don't over-answer.
    – chris
    Commented May 4, 2022 at 18:01
  • 2
    @chris what the heck? We are a technical programming site, and reading the source code is not a barrier of entry, it's the minimum required!
    – Braiam
    Commented May 4, 2022 at 18:10
  • 1
    BTW, the rules on leap years is not something unique to programming, it's astronomers job to explain when and why leap years are required. Programmers just need to implement it.
    – Braiam
    Commented May 4, 2022 at 18:16
  • 1
    @Braiam, we are a technical site for beginners as well. Everybody has to find an answer to their first questions. I am helping my son learn Python right now. He is eager, and every week he is trying something brand new. This week he decided to learn how to do video frame capture and modification, all of which was brand-new to him. Should I tell him to ignore answers on SO until he is able to understand the documentation? If he can understand the docs on his own, he wouldn't really benefit much from a community like SO. .
    – chris
    Commented May 4, 2022 at 18:16
  • 1
    @chris "we are a technical site for beginners as well" [citation urgently needed]. The tour says "Stack Overflow is a question and answer site for professional and enthusiast programmers". Note that you either know because you are paid to know, or you know because you like to know. We are not a learning resource.
    – Braiam
    Commented May 4, 2022 at 18:18
  • 2
    @braiam Even if the language designers for Java were not posting answers to "Why does Java...?" questions on SO, the formal documentation they produce for language and feature changes specifically includes discussion of the motivations, objectives and rejected alternative approaches. See JEP 400: UTF-8 by Default for a recent example. Anyone knowledgeable about Java should be able to answer a lot of "Why does Java...?" questions. The notion that "Why..." questions can only ever be answered by the original author or a mind reader is just silly.
    – skomisa
    Commented May 4, 2022 at 21:02
  • 2
    @Braiam Also note that Oleg's answer above points out that the answer "is explicitly explained in section 9.32 of the PostgreSQL official docs, so no insight into minds of the developers was needed to answer the question". Some "why" questions may be unanswerable, but a lot of them can be both answerable and valuable.
    – skomisa
    Commented May 4, 2022 at 21:06
  • @skomisa There's a child game that ask "why" until the absurd. This question went pass it. Yes, there are some well reasoned why, but lets not kid ourselves that every why question is practical. How questions "how X works" is always practical and answerable by anyone. "Why my program doesn't work" is also a why question, but mainly because it comes accompanied by "how it actually works" and "what you should do instead".
    – Braiam
    Commented May 4, 2022 at 21:35
  • 1
    @braiam, you mention that SO is a site for both "professional and enthusiast programmers." You'll certainly have noticed that words like "experienced" and "knowledgeable" were deliberately omitted. Both professional and enthusiast programmers can literally have just started a new language today. So I thank you for making my point for me - SO is a place for new programmers. It is, of course, also a place for mavens. However, I'm sorry SO is not the exclusive experts-only club you want. I really think you should accept this and move on. You could start a place like that if you'd like. ;)
    – chris
    Commented May 6, 2022 at 13:57
  • 2
    @skomisa: I assume your "don't be dogmatic" is directed at me, the author of the linked post. My intention is not to be dogmatic at all. When I contributed to this site, I answered a GREAT MANY "why" questions, and frankly wasted a lot of time doing so because I failed to read the mind of the user asking the vague question. The intention of the linked rant is rather to encourage clarity and precision in questions so as to not waste the time and energy of the people who volunteer their time to write answers. Commented Jun 13, 2022 at 23:05
  • @EricLippert Your assumption is both odd and incorrect. I have no idea why you think that I was directing my comment to you rather than the author of the answer. Regardless, note that my comment in support of "Why..." questions contained the caveats "Speaking only for [java] on SO...", and "If your question is a good one...".
    – skomisa
    Commented Jun 14, 2022 at 2:53
-9

The reason is that the only answer to "why" is "because they decided so". Instead that question should be asking "how datetime arithmetic works with intervals in postgres". I've edited the question to focus rather than the frame of mind of the devs, to how the thing works and ask others to describe it. Also, note that none of the comments/answers point towards the documentation, which would lead credence to whatever informed opinion about how it works. A good answer should be expected to reference either an article on how datetime/interval arithmetic works, and how that interacts with the interval units (months vs days vs hours, etc.).

9
  • 8
    The edit made the title less clear.
    – Laurel
    Commented May 2, 2022 at 12:39
  • 2
    @Laurel the title is accurate.
    – Braiam
    Commented May 2, 2022 at 14:04
  • 4
    "because they decided so" - and I could see their decisions in the docs and the source code which would lead to fact based answer. question doesn't ask why they decided so.
    – Alex
    Commented May 2, 2022 at 16:41
  • 2
    FWIW, I support you 100% on this (although I'm not entirely sold on your title edit). It's insane how the site has decayed. Yes, it should be quite difficult to ask a good, non-redundant question now. Literally millions of questions have already been asked. Commented May 3, 2022 at 13:48
  • 1
    @Alex at the end of the day, why they did something doesn't matter. The asker also doesn't care, he wants to know how they calculate it.
    – Braiam
    Commented May 3, 2022 at 13:53
  • 3
    BTW, it's interesting that so many people has issues with my title, yet no one seems to have a better one.
    – Braiam
    Commented May 3, 2022 at 13:55
  • 3
    I have a suggestion for a better title, @Braiam. In English, "why does X happen?" can mean "what causes X to happen?" So "why does an interval of '1 month' sometimes..." can clearly be read as "what causes an interval of '1 month' sometimes...". However, "How are months intervals internally calculated..." requires a level of detail inappropriate to the OP's original (simple) question, and requires a review of the source code to ensure accuracy. I explain this further in a comment on Joundill's answer. This is why people are saying that the original title is the better one. I agree.
    – chris
    Commented May 4, 2022 at 18:11
  • @chris I prefer English to not be ambiguous on a technical site. So, here's a better comment: I don't have a title that would be both accurate and guarantee that anyone that knows English knows exactly what I'm asking without interpreting something different.
    – Braiam
    Commented May 4, 2022 at 21:30
  • 3
    @Braiam, according to your logic, if a physics professor is asked "why do stones of different weights fall at the same speed?", The only valid answer she could give out poor student is that God (or the stones, or the universe) decided so. There is nothing unambiguous about the OP just because you are capable of rephrasing it, and as I've pointed out, your phrasing is actually problematic in very real ways. We should let people post on their own voice whenever possible, because sampling theory tells us that there are others who will search in that same voice.
    – chris
    Commented May 6, 2022 at 13:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .