<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Web Wiz Support and Community Forums : SQL error when deleting posts</title>
  <link>https://forums.webwiz.net/</link>
  <description><![CDATA[This is an XML content feed of; Web Wiz Support and Community Forums : Web Wiz Forums : SQL error when deleting posts]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Thu, 16 Apr 2026 02:23:13 +0000</pubDate>
  <lastBuildDate>Wed, 05 Oct 2005 14:14:21 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.08</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forums.webwiz.net/RSS_post_feed.asp?TID=16705</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Web Wiz Support and Community Forums]]></title>
   <url>https://forums.webwiz.net/forum_images/web_wiz_forums.png</url>
   <link>https://forums.webwiz.net/</link>
  </image>
  <item>
   <title><![CDATA[SQL error when deleting posts : OK. NOW we have something solid...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91763.html#91763</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=19649">JJLatWebWiz</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 05&nbsp;October&nbsp;2005 at 2:14pm<br /><br />OK.&nbsp; NOW we have something solid to work with.&nbsp; The cost of the actual query is going to be the same in QA and from ASP, the difference is what else happens when the query is run from the different locations.&nbsp; Using the adOpenDynamic with a server-side cursor and a CacheSize of 1 (as the delete_post.asp script is at line 217) , ADO is&nbsp;going to run a number of stored procedures to satisfy that query and multiple round-trips for each record returned by the query.&nbsp; The process also creates a temp tables on the SQL server which is probably&nbsp;part of the additional cost.&nbsp; This is true even for the stroed procedure I described, even though the cost limit override should still allow it to run.&nbsp; There are basically 2 ways to avoid the problem: <DIV>&nbsp;</DIV><OL><LI>Use a forward-only, read-only cursor if the cursor is server-side.&nbsp; Or, <LI>User a client-side cursor.</LI></OL><DIV>The problem with option 1 is that <EM>delete_post.asp</EM> uses <strong>.MoveLast</strong>, which counter-intuitively requires a cursor that can use a <strong>.MovePrevious</strong> so a forward-only cursor won't work.</DIV><DIV>&nbsp;</DIV><DIV>Option 2 might work simply by adding "<FONT face="Courier New, Courier, mono" size=1>adoCon.CursorLocation = 3</FONT>" immediately above "<FONT face="Courier New, Courier, mono" size=1>adoCon.open</FONT>" in "<EM>common.asp</EM>".&nbsp; But, I have only tested such a change in a very limited way on my MS SQL test installation.&nbsp; So far, it certainly seems to work.&nbsp; This is actually the option I would recommend from here.</DIV><DIV>&nbsp;</DIV><DIV>You can't stop the ADO connection from executing those&nbsp;stored procedures that the SQL server apparently uses to maintain the cursor.&nbsp; Now that I think about it, all this extra SQL work is taking place all the time, so for some people, it may actually speed things up by switching to a client-side cursor.&nbsp; The client-side cursor will probably put a drain on the web server, but whether or not it's a net drain or a net boost is anyone's guess.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><span style="font-size:10px"><br /><br />Edited by JJLatWebWiz - 10&nbsp;October&nbsp;2005 at 10:53am</span>]]>
   </description>
   <pubDate>Wed, 05 Oct 2005 14:14:21 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91763.html#91763</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : The cost in QA is in the area...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91702.html#91702</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=3668">Mojo_Risin</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 04&nbsp;October&nbsp;2005 at 6:29pm<br /><br />The cost in QA is in the area of 0.05 for both the SP and the original code (if I'm doing it right).<DIV>&nbsp;</DIV><DIV>I tried to execute the SP instead of the original code from the page, but I get other errors; either the following query doesn't work because the recordset is closed, or the cursor type isn't correct, depending on what kind of statement I use to execute the SP.</DIV><DIV>&nbsp;</DIV><DIV>No time to debug that problem today, so I will try again later when I get a chance.</DIV><DIV>&nbsp;</DIV><DIV>The cost of the query has worked it's way up to 131 now.&nbsp; I don't know for sure, but I suspect it's a problem on the server because the query runs almost instantly.&nbsp; According to the technical guru, who knows a heck of a lot more than SQL Server than I do, it's the code. But it strikes me as odd that the cost is gradually incrementing day by day.&nbsp; I wonder what would happen if the SQL server were stopped and restarted? Maybe there's something in memory that's not flushing.</DIV>]]>
   </description>
   <pubDate>Tue, 04 Oct 2005 18:29:26 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91702.html#91702</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : You need to run that query inQA...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91629.html#91629</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=19649">JJLatWebWiz</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 03&nbsp;October&nbsp;2005 at 8:24pm<br /><br />You need to run that query in&nbsp;QA and see if the cost is the same.&nbsp; How about the other index suggestions?&nbsp; In QA, look at the execution plan.&nbsp; Adjust the column order of the covering index and see if the execution plan and cost changes. <DIV>&nbsp;</DIV><DIV>The cost governor has a lot to do with server load, multiprocessors, and disk performance.</DIV><DIV>&nbsp;</DIV><DIV>Have you ever created a stored procedure before?&nbsp; Run this from QA:</DIV><DIV>&nbsp;</DIV><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV><FONT face="Courier New, Courier, mono" size=1>CREATE PROCEDURE wwfSP_TopicThreadsByDate <BR>@TopicID int=0</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>AS</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>SET QUERY_GOVERNOR_COST_LIMIT 0</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>declare @sql as varchar(200)</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>set @sql = 'SELECT tblThread.Thread_ID, tblThread.Message_Date FROM tblThread WHERE tblThread.Topic_ID =' + convert(varchar(8),@TopicID) + ' ORDER BY tblThread.Message_date ASC;'</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>exec (@sql)</FONT></DIV></BLOCKQUOTE><DIV>&nbsp;</DIV><DIV>That will create a simple stored procedure that does exactly the same thing as the query that gets run at line 217, but it ignores the server-wide Cost Limit.&nbsp; Now, in QA, <FONT face="Courier New, Courier, mono" size=1>exec wwfSP_TopicThreadsByDate 4</FONT> (where 4 is the Topic_ID, pick one that is very large for a good cost estimate) and compare the cost of the standard query.&nbsp; If the SP runs as it should, the <EM>delete_post.asp</EM> can then be modified to use the SP instead of the standard query.</DIV><DIV>&nbsp;</DIV><DIV>I'm mostly interested to see QA estimates the cost for the query.&nbsp; I don't understand why a simple query would be so costly with such a small recordset (big for a WWF forum but small for a SQL server).</DIV>]]>
   </description>
   <pubDate>Mon, 03 Oct 2005 20:24:46 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91629.html#91629</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts :   JJLatWebWiz wrote:To do this,...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91623.html#91623</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=3668">Mojo_Risin</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 03&nbsp;October&nbsp;2005 at 4:01pm<br /><br /><table width="99%"><tr><td class="BBquote"><img src="forum_images/quote_box.png" title="Originally posted by JJLatWebWiz" alt="Originally posted by JJLatWebWiz" style="vertical-align: text-bottom;" /> <strong>JJLatWebWiz wrote:</strong><br /><br />To do this, open&nbsp;"<EM>delete_post.asp</EM>" and find line 217.&nbsp; It should say: "<FONT face="Courier New, Courier, mono" size=1>rsCommon.Open strSQL, adoCon</FONT>".&nbsp; Change it to "<FONT face="Courier New, Courier, mono" size=1>rsCommon.Open strSQL, <FONT color=#ff0000><U>strCon</U></FONT></FONT>", and save and upload it.</td></tr></table> <DIV>&nbsp;</DIV><DIV>Thanks for the suggestion, unfortunatly it made no difference. I've also noticed that over time the cost is going up. It started at 111 and has slowly worked it's way up to 128.</DIV>]]>
   </description>
   <pubDate>Mon, 03 Oct 2005 16:01:35 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91623.html#91623</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : This actually sounds like this...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91480.html#91480</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=19649">JJLatWebWiz</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 30&nbsp;September&nbsp;2005 at 12:54pm<br /><br />This actually sounds like this might be a problem that MS SQL Server has when the index keys&nbsp;correlate closely to the actual tables.&nbsp; In such cases, the optimizing engine may choose to ignore the non-clustered indexes, thus costing much more than it should.<DIV>&nbsp;</DIV><DIV>Since you can use the Query Analyzer, I suggest you run the 2 different select statements above using the cost estimator in Query Analyzer to see if the cost and execution plan changes with different index changes.&nbsp; First, add a new multi-column index that includes the Topic_ID, Author_ID, Thread_ID, and Message_Date.&nbsp; Test the performance of the query sorted and unsorted, also sorted on Thread_ID and then on&nbsp;Message_Date.&nbsp; Change the order of the fields in the index too.</DIV><DIV>&nbsp;</DIV><DIV>I'm building a large test table to evaluate the costs&nbsp;associated with&nbsp;the different indexes.&nbsp; I think a stored procedure that includes a cost limit override will be an effective work-around.</DIV><DIV>&nbsp;</DIV><DIV>One interesting possibility is to open a new connection instead of using the persistant connection.&nbsp; I wonder if&nbsp;SQL Server is aggragating the&nbsp;costs of all the queries on the persistant connection.&nbsp; So, maybe if you open a new connection, SQL Server will estimate that cost by itself.&nbsp; I have NO idea if that's the case, but it's a quick experiment that can't hurt anything.&nbsp; To do this, open&nbsp;"<EM>delete_post.asp</EM>" and find line 217.&nbsp; It should say: "<FONT face="Courier New, Courier, mono" size=1>rsCommon.Open strSQL, adoCon</FONT>".&nbsp; Change it to "<FONT face="Courier New, Courier, mono" size=1>rsCommon.Open strSQL, <FONT color=#ff0000><U>strCon</U></FONT></FONT>", and save and upload it.</DIV>]]>
   </description>
   <pubDate>Fri, 30 Sep 2005 12:54:54 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91480.html#91480</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : Thanks for the suggestion about...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91455.html#91455</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=3668">Mojo_Risin</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 29&nbsp;September&nbsp;2005 at 8:29pm<br /><br /><P>Thanks for the suggestion about the Thread_ID change, JJL, but it made no difference whatsoever.&nbsp; Off to the drawing board again.</P>]]>
   </description>
   <pubDate>Thu, 29 Sep 2005 20:29:54 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91455.html#91455</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : Well, the webhost says the problem...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91454.html#91454</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=3668">Mojo_Risin</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 29&nbsp;September&nbsp;2005 at 8:21pm<br /><br />Well, the webhost says the problem is with the optimization of the tables (which is the default configuration that is installed with WWF). I'm not sure what happened between a couple of weeks ago and a week ago when it started, except the update to 7.92, but JJL indicates the same code is in 7.01.<DIV>&nbsp;</DIV><DIV>The host has increased the threshold to 60 which does nothing to fix the problem since it is just over half the number required.</DIV><DIV>&nbsp;</DIV><DIV>Apparently WWF is using way too many resources to delete records. I'm baffled about the sudden change. I've been using WWF on SQL Server for 2 years and no problems until now, and it's somehow my fault.&nbsp; It's an annoying problem.</DIV><DIV>&nbsp;</DIV><DIV>Guess I'll have to work on the table structure or the query structure some more.&nbsp; I haven't tried the thread_ID suggestion above, yet. BTW, the message_date field was indexed in the table already. I tried changing it from ASC to DESC to see if that made any difference. It didn't.</DIV>]]>
   </description>
   <pubDate>Thu, 29 Sep 2005 20:21:42 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91454.html#91454</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts :   JJLatWebWiz wrote:How do you...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91362.html#91362</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=3668">Mojo_Risin</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 28&nbsp;September&nbsp;2005 at 9:17pm<br /><br /><table width="99%"><tr><td class="BBquote"><img src="forum_images/quote_box.png" title="Originally posted by JJLatWebWiz" alt="Originally posted by JJLatWebWiz" style="vertical-align: text-bottom;" /> <strong>JJLatWebWiz wrote:</strong><br /><br />How do you delete topics manually?&nbsp; Does the host provide an interface to perform database functions?&nbsp; Can you run the query manually through your host's interface?</td></tr></table> <DIV>&nbsp;</DIV><DIV>I delete records manually using Enterprise Manager or Query Analyzer.</DIV><DIV>&nbsp;</DIV><DIV>I will relay your other remarks to the webhost.&nbsp; This problem is seriously affecting the administration of my forum.</DIV><DIV>&nbsp;</DIV><DIV>Thanks for the feedback.</DIV>]]>
   </description>
   <pubDate>Wed, 28 Sep 2005 21:17:39 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91362.html#91362</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : There is something seriously wrong...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91315.html#91315</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=19649">JJLatWebWiz</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 28&nbsp;September&nbsp;2005 at 12:30pm<br /><br />There is something seriously wrong with a SQL server that can't perform such a simple query.&nbsp; Doing a query against 100,000 records and returning probably less than a 10th of those records and only 2 fields should be nowhere near a cost 38.<DIV>&nbsp;</DIV><DIV>How do you delete topics manually?&nbsp; Does the host provide an interface to perform database functions?&nbsp; Can you run the query manually through your host's interface?</DIV><DIV>&nbsp;</DIV><DIV>I could probably build a stored procedure that does what you need and uses the command to override the global cost limit.&nbsp; However, a thought just occurred to me... since the Message_Date field isn't indexed, the sort process actually costs the most in that query.&nbsp; If you change the sort field from Message_Date to Thread_ID, the query cost goes down dramatically.&nbsp; There's a remote possibility that the ID sort is slightly different than the date sort, but highly unlikely.</DIV><DIV>&nbsp;</DIV><DIV>To do this, go to line 214 and change:</DIV><DIV>&nbsp;</DIV><DIV><FONT face="Courier New, Courier, mono" size=1>strSQL = "SELECT " &amp; strDbTable &amp; "Thread.Thread_ID, " &amp; strDbTable &amp; "Thread.Message_Date FROM " &amp; strDbTable &amp; "Thread WHERE " &amp; strDbTable &amp; "Thread.Topic_ID ="&nbsp; &amp; lngTopicID &amp; " ORDER BY " &amp; strDbTable &amp; "Thread.Message_date ASC;"</FONT></DIV><DIV>&nbsp;</DIV><DIV>to</DIV><DIV>&nbsp;</DIV><DIV><FONT face="Courier New, Courier, mono" size=1>strSQL = "SELECT " &amp; strDbTable &amp; "Thread.Thread_ID, " &amp; strDbTable &amp; "Thread.Message_Date FROM " &amp; strDbTable &amp; "Thread WHERE " &amp; strDbTable &amp; "Thread.Topic_ID ="&nbsp; &amp; lngTopicID &amp; " ORDER BY " &amp; strDbTable &amp; "Thread.<U><FONT color=#ff0000>Thread_ID</FONT></U> ASC;"</FONT></DIV><DIV>&nbsp;</DIV><DIV>That definitely will reduce the cost.&nbsp; Whether it reduces the cost enough, I can't answer.</DIV>]]>
   </description>
   <pubDate>Wed, 28 Sep 2005 12:30:48 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91315.html#91315</guid>
  </item> 
  <item>
   <title><![CDATA[SQL error when deleting posts : I get the error when any record...]]></title>
   <link>https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91281.html#91281</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=3668">Mojo_Risin</a><br /><strong>Subject:</strong> 16705<br /><strong>Posted:</strong> 27&nbsp;September&nbsp;2005 at 8:18pm<br /><br />I get the error when any record is deleted. It's quite annoying not to be able to delete records without generating an error, and it leaves the topic record behind if it's the only post in the thread, so I have to delete topic records manually.&nbsp; Or, are you asking how many forum records there are in total? If it's the latter, there are over 100,000 posts in the database.]]>
   </description>
   <pubDate>Tue, 27 Sep 2005 20:18:04 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/sql-error-when-deleting-posts_topic16705_post91281.html#91281</guid>
  </item> 
 </channel>
</rss>