29

I tried to edit an old question and when I hit Save Edits it showed me this error, even though I didn't touch the title. error message "Title cannot be longer than 150 characters"

Is there a new constraint, and if so, how can one possibly edit an old question without changing (shortening) its title?

7
  • 1
    I have encountered other checks, e.g. on duplicate titles, that kick in at edit submission time.
    – hardmath
    Commented Sep 13, 2015 at 18:33
  • Yes, I saw that question/problem, which is even more weird Commented Sep 13, 2015 at 18:38
  • 6
    If we're meant to hold old posts to the same standards as new ones (a principal which I often see stated here on meta), then surely the right reaction is that the title isn't a good title, so an edit to the title should also happen? Commented Sep 14, 2015 at 9:14
  • Yes, yes. I see your point. Commented Sep 14, 2015 at 9:51
  • The title has been changed. Commented Sep 14, 2015 at 9:53
  • I was thinking there is no way the title needs to be that long.
    – Matt
    Commented Sep 14, 2015 at 12:02
  • More frustrating to me are questions with 'question' or 'problem' in the title. I'm not clear how the OP gets that word into the question, but my impression is that it isn't just ancient questions that have this problem. Commented Sep 14, 2015 at 13:01

1 Answer 1

31

In the database the title is 250 characters, so somewhere back in the day the titles were longer. The limit is now 150.

That hurts when you edit an old question from before the limit was lowered. You have no other option than to edit the title, maybe salvaging relevant info by moving it in the body.

This query

select len(title) as [length of title]
, count(*) as [count]
from posts
where len(title)> 150
group by len(title)
order by 2

shows the number of question per specific title length.

Here is the proof that at least the SEDE schema has a posts table with the length of column "Title" > 150:

sede posts.title nvarchar(250)

10
  • 2
    There are 298 questions with title length > 150: data.stackexchange.com/stackoverflow/query/363483
    – Nateowami
    Commented Sep 14, 2015 at 5:23
  • 7
    That's tedious! It would be nice if, somehow, the editing process could take in account if the title was previously longer than 150 characters and allow it to still be longer than 150 characters in this case. And if the title is being reduced below the length, then the exception is lifted.
    – jeromej
    Commented Sep 14, 2015 at 5:25
  • 7
    @JeromeJ at least on this site it is only a tiny fraction of the posts, and chances that these are going to be edited at some point are likely not very high. While it would be a useful feature to a few users in a very border kind of case, there are more important things. The costs outweigh the benefit I think. Also not a lot of other sites would benefit simply because they are too new to have those too long titles.
    – simbabque
    Commented Sep 14, 2015 at 7:41
  • @simbabque I'm not sure if we can get any performance/storage improvement if we'd manage to get rid of all those lengthy title and set the row to nvarchar (150) instead. If so, this coukd be a mission.
    – jeromej
    Commented Sep 14, 2015 at 7:53
  • 3
    @JeromeJ nvarchar is a dynamic width type in sql server so it really doesn't matter if the field is 250 or 150, it only matters if all those 20.000.000 would have used 250 chars. Reducing to 150 would matter in that case. For those ~300 questions the gain would be at max 60Kb assuming they all took up the full 250 characters.
    – rene
    Commented Sep 14, 2015 at 8:21
  • 1
    @rene That's true for SQL Server itself, but it's not necessarily true for whatever client library is used to access the data. Some libraries (at least classic ADO, though I'm guessing that's not the one that's used by SO) use fixed-size buffers in the returned result sets.
    – user743382
    Commented Sep 14, 2015 at 13:28
  • Shouldn't historical questions which fall foul of newer rules be marked as requiring review or some other attention... then we might find these issues are less common where a well-meaning editor is frustrated?
    – Mr. Boy
    Commented Sep 14, 2015 at 14:33
  • 1
    The only real benefit would be to remove a tiny bit of technical debt in the form of whatever check currently caps the title length to a value shorter than the DB field. I doubt it'd be worth anyone from SE's time to do any work to facilitate the change. If someone (or several someone's) were to go through all the old questions and edit them down the schema update might be worth throwing in as part of whatever their next major DB update is. This'd probably need to be done SE wide, not just on SO though; and since the offenders are probably mostly/entirely dead, is still a debatable effort. Commented Sep 14, 2015 at 14:35
  • @Nateowami I just shorten about ~80 of those today, so I'm sure there are less than 160 long titles left now. But reducing the size of the column is not an option as we need to support long titles for deleted/undeleted questions, rollbacked questions, and history of previous revisions.
    – Cœur
    Commented Aug 6, 2017 at 17:44
  • @Nateowami only one question left with a long title.
    – Cœur
    Commented Apr 5, 2018 at 10:10

You must log in to answer this question.

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