Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can too many query requests crash SQL ?

Status
Not open for further replies.

firesign

Programmer
May 8, 2000
17
IN
hi,<br>&nbsp;&nbsp;Im developing using Coldfusion and Im using an SQL<br>database. Now, part of the code requires me to access/query<br>the database several times ...<br>&nbsp;&nbsp;Now Im thinking if 30-40 people run this same code <br>at the same time ... will it affect the SQL database server in such a way that it will give an out of memory error and<br>crash ???<br><br>thx<br>F/S
 
Each person will have a session on the database which takes up a small amount of memory per connection. The SQL Server will handle any queueing that the queries require, that is it's job in life.<br><br>If you have any problems, you are more likely to get table locking contentions than server out of memory. As always this would be a 'that depends' type question. It depends how much data each query is requesting, how the database is designed, etc. <p> <br><a href=mailto: > </a><br><a href= home</a><br>
 
The main error that I get is a <br><br>ODBC error = 37000<br>not enough memory to complete this query.<br><br>Someone said that the code may be running into an infinte<br>loop ...<br><br>F/S <p>Vince<br><a href=mailto:firesign1@altavista.net>firesign1@altavista.net</a><br><a href= home for all the Auctions.</a><br><br>
(----- Great place for Auctions -----)
 
I would imagine that the ODBC error relates to the client machine. Bill Gates would cringe if he thought that you where intimating that SQL Server could not handle over 40+ users... <p>Cal<br><a href=mailto: > </a><br><a href= > </a><br>
 
Can you show us the code in question? Is it a single line of SQL....<br><br>A classic mistake is to mention a table in the 'from' clause and not link it in the 'where' causing a cartesian query, making a massive result set and running out of memory. <p> <br><a href=mailto: > </a><br><a href= home</a><br>
 
Hi, <br>&nbsp;&nbsp;I dont know if this would make any sense...<br>But in brief ... there is the first query that picks up<br>information from the categories database. Then there are<br>loops that check each item that is queried, and cross reference check thru another query.<br><br>&nbsp;&nbsp;&nbsp;Basically, lot of queries and lot of loops.<br>And 100+ ppl will be running this at any given point of time. And within matter of hours the server is down!<br><br>F/S<br><br><br>&nbsp;&nbsp;<br>=====================================================================<br>.....<br>&lt;cfsetting enablecfoutputonly=&quot;Yes&quot;&gt;<br>&lt;cfset plist = &quot;&quot;&gt;<br>&lt;!--- get categories information ---&gt;<br><br>&lt;cfquery NAME=&quot;get_CategoryInfo&quot; DATASOURCE=&quot;#DATASOURCE#&quot;&gt;<br>SELECT parent, name, date_created, allow_sales<br>FROM categories<br>WHERE category = #category#<br>&lt;/cfquery&gt;<br><br>&lt;!--- if category not found, redirect ---&gt;<br>&lt;cfif not get_CategoryInfo.RecordCount&gt;<br>&lt;cflocation url=&quot;<A HREF=" TARGET="_new"> if parent is 0 or RecordCount is 0 ---&gt;<br>&lt;cfif category IS 0 OR get_CategoryInfo.RecordCount IS 0&gt;<br>&lt;cfset parent_available = &quot;FALSE&quot;&gt;<br>&lt;cfset category_name = &quot;Top&quot;&gt;<br>&lt;cfset public_sales = &quot;FALSE&quot;&gt;<br>&lt;cfelse&gt;<br>&lt;cfset parent_available = &quot;TRUE&quot;&gt;<br>&lt;cfset category_name = Trim(get_CategoryInfo.name)&gt;<br>&lt;cfset public_sales = get_CategoryInfo.allow_sales&gt;<br><br>&lt;!--- look up parents ---&gt;<br>&lt;cfmodule TEMPLATE=&quot;../functions/parentlookup.cfm&quot;<br>CATEGORY= &quot;#category#&quot;<br>DATASOURCE=&quot;#DATASOURCE#&quot;<br>RETURN=&quot;parents_array&quot;&gt;<br>&lt;/cfif&gt;<br><br>&lt;!--- get category_new value ---&gt;<br>&lt;cfquery NAME=&quot;CategoryNew&quot; DATASOURCE=&quot;#DATASOURCE#&quot;&gt;<br>SELECT pair AS days<br>FROM defaults<br>WHERE name = 'category_new'<br>&lt;/cfquery&gt;<br><br>&lt;!--- get number of auctions in parent catgory ---&gt;<br><br>&lt;CFMODULE TEMPLATE=&quot;tree.cfm&quot;<br>TYPE=&quot;RETRIEVE&quot;<br>DATASOURCE=&quot;#DATASOURCE#&quot;<br>PARENT=#category#<br>return=&quot;result&quot;<br>REQUIRE_LOGIN=&quot;0&quot;&gt;<br><br>&lt;!--- Set delimiter variables ---&gt;<br>&lt;cfset #int_delim# = &quot;÷&quot;&gt;<br>&lt;cfset #ext_delim# = &quot;²&quot;&gt;<br><br>&lt;cfoutput&gt;&lt;TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0 NOSHADE&gt;&lt;/cfoutput&gt;<br>&lt;cfsetting enablecfoutputonly=&quot;YES&quot;&gt;<br><br>&lt;cfloop index=&quot;l&quot; list=&quot;#result#&quot; delimiters=&quot;#ext_delim#&quot;&gt;<br>&lt;cfset totalfound = 0&gt;<br>&lt;cfif Evaluate(ListGetAt(l, 3, int_delim) + 1) LTE Variables.levelsDisplayed&gt;<br><br>&lt;!--- get catinfo ---&gt;<br>&lt;cfquery name=&quot;getCatInfo&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT date_created, allow_sales<br>FROM categories<br>WHERE category = #ListGetAt(l, 1, int_delim)# <br>&lt;/cfquery&gt;<br>&lt;!--- parent total child count ---&gt;<br>&lt;cfquery name=&quot;ParentTotal&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT child_count from categories<br>where category = #ListGetAt(l, 1, int_delim)#<br>&lt;/cfquery&gt;<br><br>&lt;!-- Check to see if the Parent has kids ---&gt;<br>&lt;!--- ***** starting level one check ***** ---&gt;<br>&lt;cfset levelone = &quot;false&quot;&gt; <br>&lt;cfset levelonea = &quot;false&quot;&gt; <br>&lt;cfif ListGetAt(l, 4, int_delim) GT 0 and ListGetAt(l, 3, int_delim) EQ 0&gt;<br>&lt;cfset Vlist = &quot;&quot;&gt;<br>&lt;!--- get the kid category nos ---&gt;<br>&lt;cfquery name=&quot;check1&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT category as CateChk<br>FROM categories<br>WHERE parent = #ListGetAt(l, 1, int_delim)#<br>&lt;/cfquery&gt;<br><br>&lt;!--- dump that into the list ---&gt; <br>&lt;cfloop query=&quot;check1&quot;&gt;<br>&lt;cfset #Vlist# = #listAppend (Vlist,&quot;#CateChk#&quot;)#&gt;<br>&lt;/cfloop&gt; <br><br>&lt;!--- search the list for the child category having children ---&gt;<br>&lt;cfloop index=&quot;aa&quot; list=&quot;#vlist#&quot;&gt;<br><br>&lt;cfquery name=&quot;check2&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT category as CateChk1 from categories<br>WHERE parent = #aa#<br>&lt;/cfquery&gt; <br><br>&lt;!--- *** LeveloneA check *** ---&gt;<br>&lt;cfif #check2.recordcount# EQ 0&gt;<br><br>&lt;!--- get all the items that match callist from ITEMS ---&gt;<br>&lt;cfquery name=&quot;GetSearch&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT COUNT(itemnum) AS found<br>FROM items<br>WHERE (category1 = #aa# OR category2 = #aa#) <br>AND status = 1<br>AND date_start &lt; #TIMENOW#<br>AND date_end &gt; #TIMENOW# <br>&lt;/cfquery&gt; <br><br>&lt;cfset totalfound = totalfound + #Getsearch.found#&gt; <br>&lt;cfset levelonea = &quot;true&quot;&gt; <br>&lt;/cfif&gt;<br><br>&lt;!--- dump categories in to calist ---&gt;<br>&lt;cfif levelonea EQ &quot;false&quot;&gt;<br>&lt;cfset calist=&quot;&quot;&gt;<br>&lt;cfloop query=&quot;check2&quot;&gt;<br>&lt;cfset #calist# = #listAppend (calist,&quot;#CateChk1#&quot;)#&gt;<br>&lt;/cfloop&gt; <br><br>&lt;!--- get all the items that match callist from ITEMS ---&gt;<br>&lt;cfloop index=&quot;ab&quot; from=&quot;1&quot; to=&quot;#check2.recordcount#&quot;&gt;<br>&lt;cfquery name=&quot;itemGet&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT COUNT(itemnum) AS found<br>FROM items<br>WHERE (category1 = #listGetAt(calist,ab)# OR category2 = #listGetAt(calist,ab)#) <br>AND status = 1<br>AND date_start &lt; #TIMENOW#<br>AND date_end &gt; #TIMENOW# <br>&lt;/cfquery&gt; <br>&lt;cfset totalfound = totalfound + #itemGet.found#&gt; <br>&lt;cfset levelone = &quot;true&quot;&gt; <br>&lt;/cfloop&gt;<br>&lt;/cfif&gt;<br><br>&lt;/cfloop&gt;<br>&lt;/cfif&gt;<br><br>&lt;!--- now for the second level ---&gt;<br>&lt;cfset leveltwo = &quot;false&quot;&gt;<br>&lt;cfif ListGetAt(l, 4, int_delim) GT 0 and ListGetAt(l, 3, int_delim) GT 0 and #levelone# EQ &quot;false&quot; and #levelonea# EQ &quot;false&quot;&gt; <br>&lt;cfset valist = &quot;&quot;&gt;<br><br>&lt;!--- get all the categories for the second level ---&gt;<br>&lt;cfquery name=&quot;getC2&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT category as cchk<br>from categories<br>WHERE parent = #ListGetAt(l, 1, int_delim)#<br>&lt;/cfquery&gt;<br><br>&lt;!--- make a list of it ---&gt;<br>&lt;cfloop query=&quot;getC2&quot;&gt;<br>&lt;cfset #Valist# = #listAppend (Valist,&quot;#CChk#&quot;)#&gt;<br>&lt;/cfloop&gt; <br><br>&lt;!--- now do the check ---&gt;<br>&lt;cfloop index=&quot;ab1&quot; list=&quot;#Valist#&quot;&gt;<br>&lt;cfquery name=&quot;itemGets&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT COUNT(itemnum) AS found<br>FROM items<br>WHERE (category1 = #ab1# OR category2 = #ab1#) <br>AND status = 1<br>AND date_start &lt; #TIMENOW#<br>AND date_end &gt; #TIMENOW# <br>&lt;/cfquery&gt; <br>&lt;cfset totalfound = totalfound + #itemGets.found#&gt; <br><br>&lt;cfset leveltwo = &quot;true&quot;&gt; <br>&lt;/cfloop&gt;<br>&lt;/cfif&gt;<br><br><br>&lt;!--- now total the third level ---&gt;<br>&lt;cfset levelthree = &quot;false&quot;&gt;<br>&lt;cfif ListGetAt(l, 4, int_delim) EQ 0 and #levelone# EQ &quot;false&quot; and #leveltwo# EQ &quot;false&quot; and #levelonea# EQ &quot;false&quot;&gt; <br>&lt;cfquery name=&quot;getC&quot; datasource=&quot;#DATASOURCE#&quot;&gt;<br>SELECT COUNT(itemnum) AS total_auctions<br>FROM items<br>WHERE (category1 = #ListGetAt(l, 1, int_delim)#<br>OR category2 = #ListGetAt(l, 1, int_delim)#) <br>&lt;/cfquery&gt;<br>&lt;cfset totalfound = totalfound + #getc.total_auctions#&gt;<br>&lt;cfset levelthree = &quot;true&quot;&gt;<br>&lt;/cfif&gt;<br><br>&lt;!--- the final output comes here ---&gt; <br>=======================================================================<br> <p> <br><a href=mailto: > </a><br><a href=
 
Too many requests cannot crash the Sql server reason being<br>that if u r code goes into infinite loop the cpu utilisation will be 100% and if it persists for along time the conncection will be severed.
 
OK !!<br>&nbsp;This is exactly what I was told ... that some part of the code was going into and infinite loop.<br>But for some reason no one could detect that particular page that does this ...<br>&nbsp;&nbsp;&nbsp;How would i know which part of the code goes into and infinte loop. All the loops are in for a specific length.<br><br>&nbsp;&nbsp;Is there a way of finding out where this might be happening ??? Cause I have the site on a test server here.<br>I also have my task manager opened up. So I can see the activity that takes place when ever there is a query<br>run. And yeah, for a brief 2 seconds there is the CPU<br>utilization is at 100% and then fades away to a steady 9%.<br><br>&nbsp;&nbsp;So, if there is some form of activity taking place due to the infinite loop, I would know ....right !<br><br>WHAT DO I DO NOW ??<br><br>regards,<br>F/S<br><br> <p> <br><a href=mailto: > </a><br><a href=
 
Use SQL profiler to watch what sql is being sent to the db from your app. <br><br>Often what you code can actually end up sending many request to the backend i.e. cursors can cause to network passes for each record requested from a recordset... <p>Cal<br><a href=mailto: > </a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top