I've found the issue. Over the last few weeks the weekly refresh times got improved, a lot. From 6 to 8 hours we're now down to well under an hour.
One of the improvements was revealed to me by Aaron and involves pre-staging the PostHistory table. With that in mind I looked at your query to see if PostHistory was invovled. I then ran this query to see on which columns there were collation mismatches.
You can see both SQL_Latin1_General_CP1_CI_AS
and SQL_Latin1_General_CP1_CS_AS
are used. The former is the database default, the latter how most columns in the schema were created. Most is the critical point here. It looks like the tables and views and their columns that are involved in one way or the other with the new and much needed improvements now have a different collation, or to be precise: the database default collation. See also: Let the default collation of the SEDE databases match the dominant collation used for the nvarchar columns
To solve the issue with your specific query for now we have to sprinkle a few COLLATE
hints in the query to tell SQL Server how to deal with these differences in collation.
In this query I've made these changes:
...
coalesce(Users.DisplayName, PostHistory.UserDisplayName collate SQL_Latin1_General_CP1_CS_AS),
...
in both the projection and the group by of the UserName
column inside the Editor's CTE.
One of the debug option is to run each select of the CTE separately, for example by running this:
select
PostHistory.PostId as PostId,
PostHistory.UserId as UserId,
coalesce(Users.DisplayName, PostHistory.UserDisplayName /* collate SQL_Latin1_General_CP1_CS_AS */) as UserName,
min(PostHistory.CreationDate) as FirstEditDate
from
( select Id as PostId, ParentId, PostTypeId
from Posts
where OwnerUserId = 811) PostsByUser
join PostHistory on PostHistory.PostId = PostsByUser.PostId
left join Users on Users.Id = PostHistory.UserId
where
PostHistory.PostHistoryTypeId in (4,5) -- edit body/title
and (PostHistory.UserId != 811 or PostHistory.UserId is null)
group by
PostHistory.PostId,
PostHistory.UserId,
coalesce(Users.DisplayName, PostHistory.UserDisplayName /* collate SQL_Latin1_General_CP1_CS_AS */)
You'll get the error:
Line 1: Cannot resolve collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "SQL_Latin1_General_CP1_CS_AS" in CASE operator occurring in GROUP BY statement column 4.
The line number indicator isn't very helpful here, but at least you can now have localized the issue to only this query.
Keep in mind SEDE is updated once a week on Sunday.
Use the awesome SEDE Tutorial written by the unforgettable Monica Cellio.
Say "Hi" in SEDE chat.
filter
can return complete data on each answer, if that's what you're wanting. Also of note is that if what you're really wanting is >= 2 score, rather than >= 2 upvotes, then the/search/excerpts
endpoint can be used to return a much more narrow set of results.stack-to-blog.py
reads ALL answers and questions and then selects the good ones for the website. It also ignores self-accept answers if up votes <2
. The spirit of the question was how to fix the SEDE bug, not how to filter Q&A. As stated it's been working fine for a few years. I'm thinking there is a specific Question or Answer it is choking on and then I could simply edit it in SE and rerun the query.