YAFLogo

BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
4 months ago
After upgrading to v3.1.8 the posting has become much slower. Sometimes it can take around approximately 10 seconds for a post containing only text to be saved. With the previously installed version (2.2.2) it was almost instant.

Is there a know bug (it often seems quite slow making a post on this support forum) which causes this and a possible workaround? 

BWG 
Sponsor

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
4 months ago
It possible that the email sending is causing this.

can you do a test and remove the line..

 this.Get<ISendNotification>().ToWatchingUsers(newMessage);

from the postmessage.ascx.cs and then try to post a message to an existing topic
BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
4 months ago
Originally Posted by: tha_watcha 

It possible that the email sending is causing this.

can you do a test and remove the line..

 this.Get&lt;ISendNotification&gt;().ToWatchingUsers(newMessage);

from the postmessage.ascx.cs and then try to post a message to an existing topic




Just tested and it doesn't seem to make much difference. Perhaps a little quicker but still very slow. (I also PM'd you with more info a little earlier)
BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
4 months ago
I'm doing more testing at the moment using SQL Server Profile. I've attached a trace from my local dev server generated when posting a reply to an existing topic. 

 YAF_3_1_8ii.zip You have insufficient rights to see the content.
BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
4 months ago
This is the SQL which appears to be very slow. It's taking about 6 seconds and is pulling back all 330,000 records in the database on my dev server.  I'm not sure what it is doing but could it be modified to bring back only top x rows?



exec sp_executesql N'SELECT "dbo"."yaf_Message"."MessageID" AS "ID", "dbo"."yaf_Message"."TopicID", "dbo"."yaf_Message"."ReplyTo", "dbo"."yaf_Message"."Position", "dbo"."yaf_Message"."Indent", "dbo"."yaf_Message"."UserID", "dbo"."yaf_Message"."UserName", "dbo"."yaf_Message"."Posted", "dbo"."yaf_Message"."Message" AS "MessageText", "dbo"."yaf_Message"."IP", "dbo"."yaf_Message"."Edited", "dbo"."yaf_Message"."Flags", "dbo"."yaf_Message"."EditReason", "dbo"."yaf_Message"."IsModeratorChanged", "dbo"."yaf_Message"."DeleteReason", "dbo"."yaf_Message"."EditedBy", "dbo"."yaf_Message"."ExternalMessageId", "dbo"."yaf_Message"."ReferenceMessageId", "dbo"."yaf_Message"."UserDisplayName" 
FROM "dbo"."yaf_Topic" INNER JOIN "dbo"."yaf_Message" ON ("dbo"."yaf_Message"."TopicID" = "dbo"."yaf_Topic"."TopicID")
WHERE ((("dbo"."yaf_Topic"."ForumID" = @0) AND (("dbo"."yaf_Topic"."Flags" & @1) <> @2)) AND (("dbo"."yaf_Message"."Flags" & @3) = @4))
ORDER BY "dbo"."yaf_Message"."Posted" DESC',N'@0 int,@1 int,@2 int,@3 int,@4 int',@0=2,@1=8,@2=8,@3=24,@4=16



Further testing shows that the message is inserted into the database very quickly. 

If I open another browser and login as a different user I can see the new message before the browser which I am posting from refreshes. So the slowdown is happening after the database insert.


Edit: I've identified the code causing the slowdown. It is in YAF.Core\Model\MessageRepositoryExtensions.cs and I comment out the lines below the performance is massively improved. However, I'm not really sure what that code does and whether it is needed?



        if (flags.IsApproved)
        {
            repository.Approve(newMessageId, forum.ID);
            BoardContext.Current.Get<IRaiseEvent>;().Raise(new UpdateForumStatsEvent(forum.ID));
        }


Edit 2: It's the update to the forum stats which is causing the problems. Commenting out as below makes a massive difference to posting time.

BoardContext.Current.Get<IRaiseEvent>().Raise(new UpdateForumStatsEvent(forumId));

in AF.Core\Model\MessageRepositoryExtensions.cs:
public static Message SaveNew
public static void Approve

 
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
4 months ago
Thanks for the report, issue should be fixed now in the source repo
Zero2Cool
3 months ago
Originally Posted by: BWG 

This is the SQL which appears to be very slow. It's taking about 6 seconds and is pulling back all 330,000 records in the database on my dev server.  I'm not sure what it is doing but could it be modified to bring back only top x rows?



exec sp_executesql N&#39;SELECT &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;MessageID&quot; AS &quot;ID&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;TopicID&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;ReplyTo&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Position&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Indent&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;UserID&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;UserName&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Posted&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Message&quot; AS &quot;MessageText&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;IP&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Edited&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Flags&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;EditReason&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;IsModeratorChanged&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;DeleteReason&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;EditedBy&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;ExternalMessageId&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;ReferenceMessageId&quot;, &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;UserDisplayName&quot;&#160;
FROM &quot;dbo&quot;.&quot;yaf_Topic&quot; INNER JOIN &quot;dbo&quot;.&quot;yaf_Message&quot; ON (&quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;TopicID&quot; = &quot;dbo&quot;.&quot;yaf_Topic&quot;.&quot;TopicID&quot;)
WHERE (((&quot;dbo&quot;.&quot;yaf_Topic&quot;.&quot;ForumID&quot; = @0) AND ((&quot;dbo&quot;.&quot;yaf_Topic&quot;.&quot;Flags&quot; &amp; @1) &lt;&gt; @2)) AND ((&quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Flags&quot; &amp; @3) = @4))
ORDER BY &quot;dbo&quot;.&quot;yaf_Message&quot;.&quot;Posted&quot; DESC&#39;,N&#39;@0 int,@1 int,@2 int,@3 int,@4 int&#39;,@0=2,@1=8,@2=8,@3=24,@4=16



Further testing shows that the message is inserted into the database very quickly. 

If I open another browser and login as a different user I can see the new message before the browser which I am posting from refreshes. So the slowdown is happening after the database insert.


Edit: I've identified the code causing the slowdown. It is in YAF.Core\Model\MessageRepositoryExtensions.cs and I comment out the lines below the performance is massively improved. However, I'm not really sure what that code does and whether it is needed?



&#160; &#160; &#160; &#160; if (flags.IsApproved)
&#160; &#160; &#160; &#160; {
&#160; &#160; &#160; &#160; &#160; &#160; repository.Approve(newMessageId, forum.ID);
&#160; &#160; &#160; &#160; &#160; &#160; BoardContext.Current.Get&lt;IRaiseEvent&gt;;().Raise(new UpdateForumStatsEvent(forum.ID));
&#160; &#160; &#160; &#160; }


Edit 2: It's the update to the forum stats which is causing the problems. Commenting out as below makes a massive difference to posting time.

BoardContext.Current.Get&lt;IRaiseEvent&gt;().Raise(new UpdateForumStatsEvent(forumId));

in AF.Core\Model\MessageRepositoryExtensions.cs:
public static Message SaveNew
public static void Approve

 



I just wanted to say, you freaking rock for digging into this and finding a solution!
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button