[thelist] Re: getRows() (was: commenting code)

Madhu Menon madhum at trisoft.net
Fri Feb 16 08:15:05 CST 2001


Matt wrote:
> This is only faster when you have a large number of rows returned. If I
recall
> correctly, it was something like 250 rows.

I do believe you're mistaken there, Matt.

http://www.learnasp.com/advice/whygetrows.asp

<quote>

"Does it matter for small amounts of data?

YES!!!!!!!!

My site has SQLserver scripts that run like lightning. I once needed to fill
a 9 item listbox from Access and got 90 sec script timeouts with movenext.
Getstring never timed out. So in a real production situation it makes weak
databases feasible and of course reduces the load on more industrial
back-ends so maybe the SQLserver doesn't need as many indexes or RAM
upgrades."

</quote>

Looping through an array is faster than looping through a recordset. If
nothing else, it allows you to close the connection faster, which makes it
easier on server resources. 


Norman wrote:
> Just a quick amendment to Madhu's comment about seperating ASP and HTML
into
> seperate blocks and using response.writes.  My understanding is that
> mutliple calls to the response object slows things down as well.  It's
best
> to build the entire page as a string, and then response.write it all with
> just the one call.  Would I be correct in assuming this?

Yes Norman, you're right.

The trade-off is in readability. If I'm trying to debug a script, I find it
useful to step through each Response.Write statement to see where I'm making
a mistake. Your mileage may vary. 

Basically, my options boil down to these:

1) [Lots of HTML here]
<td>Field Name: <%=RsDetails("FieldName")%> </td>

Very readable, but slower.

2) [Lots of Response.Write statements here]
Response.Write "<td>Field Name: " & RsDetails("FieldName") & "</td>"

Sorta middle ground. I can still make out lines clearly. Not as readable as
no. 1 but mildly faster.

3) strHTML = "[Lots of continuous concatenations of HTML here]" & "<td>Field
Name: " & RsDetails("FieldName") & "</td>"
Response.Write strHTML

Not very readable (IMHO), but fast. Again, your mileage may vary. This is
just my comfort level. Don't flame me ;)

sgd had given a tip a long time ago on thelist about replacing your
Response.Write statements with a call to a function called R (or p) that
takes a string as a parameter and just does a Response.Write of it. Good
tip, IMO. Makes code a good bit more readable. If you're an old Basic fan,
call the function Print ;)

Cheers,

Madhu

<<<   *   >>>
Madhu Menon
Head - User Experience Group
Trisoft Systems Pvt. Ltd.  
Global Software Services

Work: http://www.trisoft.net
Personal: http://madman.weblogs.com 

(Don't look at me. I didn't add the disclaimer. Damn it! Martin B has one
too ;)


------------------------DISCLAIMER--------------------------.
The contents of this E-mail (including the contents of the enclosure/(s) or
attachment/(s) if any) are privileged and confidential material of Trisoft
Systems Private Limited and should not be disclosed to, used by or copied in
any manner by anyone other than the intended addressee/(s). If this E-mail
(including the enclosure/(s) or attachment/(s)if any ) has been received in
error, please advise the sender immediately and delete it from your system.
The views expressed in this E-mail message (including the enclosure/(s)or
attachment/(s) if any) are those of the individual sender, except where the
sender expressly, and with authority, states them to be the views of Trisoft
Systems Private Limited.






More information about the thelist mailing list