In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
CREATE INDEX restoredconversati_idx_convid_chat_id ON dbo.RestoredConversationLinesConcatenated_WithChatID (ConvId,chat_id);
SELECT
* INTO dbo.RestoredConversationLinesConcatenated_WithChatIDWithoutSingleChats
FROM
dbo.RestoredConversationLinesConcatenated_WithChatID c EXCEPT SELECT
*
FROM
dbo.RestoredConversationLinesConcatenated_WithChatID b
WHERE
NOT EXISTS (
SELECT
1
FROM
dbo.RestoredConversationLinesConcatenated_WithChatID a
WHERE
a.ConvId = b.ConvId
AND a.chat_id <> b.chat_id
)