473,770 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Speed Tricks

I just posted an article I wrote called ASP Speed Tricks. It covers
techniques to optimize output of database data in HTML, for
both simple tables and complex tables. More advanced ASP authors might
be interested in the complex table optimizations. Please check it out at:

http://www.somacon.com/aspdocs/

Hope you enjoy,
Shailesh

Please reply at http://www.somacon.com/contact.php

Jul 19 '05 #1
17 4023
a) Use GetRows/GetString rather than looping through recordsets

b) In the "complex table" scenario, do a JOIN to retrieve all the data as a
single resultset. Combine with .GetRows.

It's not just about speed - you need to look at scalability as well.
Eliminating the need to mulitple recordset objects, and reducing the amount
of time required for connections etc to be held open increases scalability
in terms of the number of users your webapp can support.

Cheers
Ken

"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:IQ******** **************@ twister.columbu s.rr.com...
: I just posted an article I wrote called ASP Speed Tricks. It covers
: techniques to optimize output of database data in HTML, for
: both simple tables and complex tables. More advanced ASP authors might
: be interested in the complex table optimizations. Please check it out at:
:
: http://www.somacon.com/aspdocs/
:
: Hope you enjoy,
: Shailesh
:
: Please reply at http://www.somacon.com/contact.php
:
Jul 19 '05 #2
Good points. I did not cover GetRows or GetString, as they preclude the
possibility of using VBScript to perform additional formatting to cell
contents. I know that the formatting can be done in the SQL query
itself, but this is usually a little harder and less flexible.

I talked about using Join to retrieve all the 'complex' data as a single
recordset in the section "Methods to Avoid". The rationale for avoiding
this is that the primary table data will be repeated for each joined row
of the secondary table, which in most circumstances would cause excess
overhead. But I can imagine circumstances when this would work out faster.

I am reading up on disconnected recordsets. Otherwise, I don't have
much experience with scalability, as the app I've been working on is for
the Intranet. I should mention this in the article.

Thank you very much for your comments.

Shailesh

Ken Schaefer wrote:
a) Use GetRows/GetString rather than looping through recordsets

b) In the "complex table" scenario, do a JOIN to retrieve all the data as a
single resultset. Combine with .GetRows.

It's not just about speed - you need to look at scalability as well.
Eliminating the need to mulitple recordset objects, and reducing the amount
of time required for connections etc to be held open increases scalability
in terms of the number of users your webapp can support.

Cheers
Ken

"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:IQ******** **************@ twister.columbu s.rr.com...
: I just posted an article I wrote called ASP Speed Tricks. It covers
: techniques to optimize output of database data in HTML, for
: both simple tables and complex tables. More advanced ASP authors might
: be interested in the complex table optimizations. Please check it out at:
:
: http://www.somacon.com/aspdocs/
:
: Hope you enjoy,
: Shailesh
:
: Please reply at http://www.somacon.com/contact.php
:


Jul 19 '05 #3

"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:_p******** **************@ twister.columbu s.rr.com...
: Good points. I did not cover GetRows or GetString, as they preclude the
: possibility of using VBScript to perform additional formatting to cell
: contents. I know that the formatting can be done in the SQL query
: itself, but this is usually a little harder and less flexible.
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~

With .GetRows() you can do the formatting as you access the array elements.

..GetString() is faster, but not suitable for situations where flexible
formatting options are required.

~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
: I talked about using Join to retrieve all the 'complex' data as a single
: recordset in the section "Methods to Avoid". The rationale for avoiding
: this is that the primary table data will be repeated for each joined row
: of the secondary table, which in most circumstances would cause excess
: overhead. But I can imagine circumstances when this would work out
faster.
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~

Personally I think the use of multiple recordsets would generally cause more
overhead. I suppose it depends how much info is repeated for each "parent"
record.

Cheers
Ken
Jul 19 '05 #4
I agree - for very large recordsets I suspect that time is spent allocating
memory. However I don't think it's practical (or normal) to dump 20,000
records to a webpage :-)

For a webpage that has a lot of reports, you can do something like this:

' Open connection
' Open RS and GetRows (first resultset)
' Open RS and GetRows (second resultset)
' Open RS and GetRows (third resultset)
' Close Connection
'
' Lots of other stuff here
'
'
' Write out first resultset
' Write out second resultset
' Write out third resultset

That way, your connection is only open for a small part of the webpage,
which means (usually) that you can support more clients.

Cheers
Ken
"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:Jz******** **************@ twister.columbu s.rr.com...
: I just found that GetString can be slower than looping through the
: recordset. I modified my example simpletable5.as p to check.
:
: This is the code snippet with GetString:
:
: Response.write objRS.GetString (, , vbTab, vbCrLf, "&nbsp;")
:
: For 20,000 records, the server time was about 2.13 seconds.
:
: This is the current simpletable5.as p algorithm, which produces
: the same output with looping through the Recordset:
:
: Do While Not objRS.EOF
: Response.write objField0
: Response.write vbTab
: Response.write objField1
: Response.write vbTab
: Response.write objField2
: Response.write vbTab
: Response.write objField3
: Response.write vbTab
: Response.write vbCrLf
: objRS.MoveNext
: Loop
:
: For 20,000 records, the server time was about 1.25 seconds.
:
: This is rather surprising to me! I think it is because GetString needs
: to do memory allocation to create the output string, whereas
: Response.write just dumps out the data as soon as it is generated.
:
: Shailesh
:
: Ken Schaefer wrote:
:
: > a) Use GetRows/GetString rather than looping through recordsets
: >
: > b) In the "complex table" scenario, do a JOIN to retrieve all the data
as a
: > single resultset. Combine with .GetRows.
: >
: > It's not just about speed - you need to look at scalability as well.
: > Eliminating the need to mulitple recordset objects, and reducing the
amount
: > of time required for connections etc to be held open increases
scalability
: > in terms of the number of users your webapp can support.
: >
: > Cheers
: > Ken
: >
: > "Shailesh Humbad" <hu******@hotma il.com> wrote in message
: > news:IQ******** **************@ twister.columbu s.rr.com...
: > : I just posted an article I wrote called ASP Speed Tricks. It covers
: > : techniques to optimize output of database data in HTML, for
: > : both simple tables and complex tables. More advanced ASP authors
might
: > : be interested in the complex table optimizations. Please check it out
at:
: > :
: > : http://www.somacon.com/aspdocs/
: > :
: > : Hope you enjoy,
: > : Shailesh
: > :
: > : Please reply at http://www.somacon.com/contact.php
: > :
: >
: >
:
Jul 19 '05 #5
It would be nice to one day be able to dump 20000 records to a webpage.
The long list would definitely be useful for something like an embedded
search box, as in http://www.somacon.com/phpref/ . Anyway, GetString is
only slower for the larger recordsets, as you pointed out. It is only
somewhat faster than the optimized looping for the smaller recordsets.
Here are the test results for the other cases:

Records GetString Time Looping Time KBytes
1000 0.08 0.10 25
2000 0.13 0.17 52
10000 0.50 0.67 262
20000 2.13 1.25 536

Time is seconds to run the entire page, and is the approximate average
of 5-10 test runs. KBytes is the size of the output of the page.

Shailesh

Shailesh Humbad wrote:
I just found that GetString can be slower than looping through the
recordset. I modified my example simpletable5.as p to check.

This is the code snippet with GetString:

Response.write objRS.GetString (, , vbTab, vbCrLf, "&nbsp;")

For 20,000 records, the server time was about 2.13 seconds.

This is the current simpletable5.as p algorithm, which produces
the same output with looping through the Recordset:

Do While Not objRS.EOF
Response.write objField0
Response.write vbTab
Response.write objField1
Response.write vbTab
Response.write objField2
Response.write vbTab
Response.write objField3
Response.write vbTab
Response.write vbCrLf
objRS.MoveNext
Loop

For 20,000 records, the server time was about 1.25 seconds.

This is rather surprising to me! I think it is because GetString needs
to do memory allocation to create the output string, whereas
Response.write just dumps out the data as soon as it is generated.

Shailesh

Ken Schaefer wrote:
a) Use GetRows/GetString rather than looping through recordsets

b) In the "complex table" scenario, do a JOIN to retrieve all the data
as a
single resultset. Combine with .GetRows.

It's not just about speed - you need to look at scalability as well.
Eliminating the need to mulitple recordset objects, and reducing the
amount
of time required for connections etc to be held open increases
scalability
in terms of the number of users your webapp can support.

Cheers
Ken

"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:IQ******** **************@ twister.columbu s.rr.com...
: I just posted an article I wrote called ASP Speed Tricks. It covers
: techniques to optimize output of database data in HTML, for
: both simple tables and complex tables. More advanced ASP authors might
: be interested in the complex table optimizations. Please check it
out at:
:
: http://www.somacon.com/aspdocs/
:
: Hope you enjoy,
: Shailesh
:
: Please reply at http://www.somacon.com/contact.php
:


Jul 19 '05 #6
hailesh Humbad" <hu******@hotma il.com> wrote in message
news:IQ******** **************@ twister.columbu s.rr.com...
I just posted an article I wrote called ASP Speed Tricks. It covers
techniques to optimize output of database data in HTML, for
both simple tables and complex tables. More advanced ASP authors might
be interested in the complex table optimizations. Please check it out at:

http://www.somacon.com/aspdocs/
Another thing bad for scalability AND performance is this

' Connect to the data source
objCN.Connectio nString = "DSN=datasource "
objCN.Open

You should advise to use OLEDB instead of ODBC.
success

--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm

Hope you enjoy,
Shailesh

Please reply at http://www.somacon.com/contact.php


Jul 19 '05 #7
"Bob Barrows" <re*******@yaho o.com> wrote in message
news:uf******** ******@TK2MSFTN GP12.phx.gbl...
Shailesh Humbad wrote:

Set rs = server.createob ject("adodb.rec ordset")
objCN.Procedure OrQueryName param1,..,param M, rs And I would recommand not to use SErver.Createob ject but CreateObjecet
avoiding another extra code-layer that is not necesarry on W2k and higher.
(It was however on NT4)...
;-) Bob Barrows


Jul 19 '05 #8
Egbert Nierop (MVP for IIS) wrote:
"Bob Barrows" <re*******@yaho o.com> wrote in message
news:uf******** ******@TK2MSFTN GP12.phx.gbl...
Shailesh Humbad wrote:

Set rs = server.createob ject("adodb.rec ordset")
objCN.Procedure OrQueryName param1,..,param M, rs

And I would recommand not to use SErver.Createob ject but CreateObjecet
avoiding another extra code-layer that is not necesarry on W2k and
higher. (It was however on NT4)...
;-)


Oops, I forgot :-)
I'm still on NT4 - it will be easier to remember when we finally move to
IIS5, I hope :-)

Thx,
Bob

Jul 19 '05 #9
In my Intranet medical office application, many of the pages allow the
user to select a patient, physician, or insurance, and these lists can
easily have up to thousands of entries. The asynchronous server call
has too high latency for common, repeated use. On the other hand, I
agree that scroll bars and drop down lists are awful user interface
elements. I have written an extensive article on this, and have come up
with what I think is a better solution. It implements the Winamp "Jump
To File" feature in Javascript. If you're interested, read about it here:

http://somacon.com/jumpto/userinterface.php

And try it out and get the source code here:

http://www.somacon.com/phpref/

This interface requires that all the options are pre-loaded in the page
that is sent to the browser. Since people are moving to higher
bandwidth connections all the time, and the Intranet is already fast
enough, this is more and more becoming acceptable in practice.

Shailesh
Chris Barber wrote:
There are better ways to do this that don't entail sending 20,000 records to
the client browser. Some form of asynchronous call to the server to process
the search term and return a list of associated entries. After all, who is
every going to scroll down a list that has 20,000 entries. I get exasperated
just scrolling through about 50-100.

Chris.

"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:pf******** **************@ twister.columbu s.rr.com...
It would be nice to one day be able to dump 20000 records to a webpage.
The long list would definitely be useful for something like an embedded
search box, as in http://www.somacon.com/phpref/ . Anyway, GetString is
only slower for the larger recordsets, as you pointed out. It is only
somewhat faster than the optimized looping for the smaller recordsets.
Here are the test results for the other cases:

Records GetString Time Looping Time KBytes
1000 0.08 0.10 25
2000 0.13 0.17 52
10000 0.50 0.67 262
20000 2.13 1.25 536

Time is seconds to run the entire page, and is the approximate average
of 5-10 test runs. KBytes is the size of the output of the page.

Shailesh

Shailesh Humbad wrote:
I just found that GetString can be slower than looping through the
recordset. I modified my example simpletable5.as p to check.

This is the code snippet with GetString:

Response.wri te objRS.GetString (, , vbTab, vbCrLf, "&nbsp;")

For 20,000 records, the server time was about 2.13 seconds.

This is the current simpletable5.as p algorithm, which produces
the same output with looping through the Recordset:

Do While Not objRS.EOF
Response.write objField0
Response.write vbTab
Response.write objField1
Response.write vbTab
Response.write objField2
Response.write vbTab
Response.write objField3
Response.write vbTab
Response.write vbCrLf
objRS.MoveNext
Loop

For 20,000 records, the server time was about 1.25 seconds.

This is rather surprising to me! I think it is because GetString needs
to do memory allocation to create the output string, whereas
Response.wri te just dumps out the data as soon as it is generated.

Shailesh

Ken Schaefer wrote:
a) Use GetRows/GetString rather than looping through recordsets

b) In the "complex table" scenario, do a JOIN to retrieve all the data
as a
single resultset. Combine with .GetRows.

It's not just about speed - you need to look at scalability as well.
Eliminati ng the need to mulitple recordset objects, and reducing the
amount
of time required for connections etc to be held open increases
scalabili ty
in terms of the number of users your webapp can support.

Cheers
Ken

"Shailesh Humbad" <hu******@hotma il.com> wrote in message
news:IQ**** *************** ***@twister.col umbus.rr.com...
: I just posted an article I wrote called ASP Speed Tricks. It covers
: techniques to optimize output of database data in HTML, for
: both simple tables and complex tables. More advanced ASP authors
might
: be interested in the complex table optimizations. Please check it
out at:
:
: http://www.somacon.com/aspdocs/
:
: Hope you enjoy,
: Shailesh
:
: Please reply at http://www.somacon.com/contact.php
:



Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2992
by: Rob Ristroph | last post by:
I have tried out PHP 5 for the first time (with assistance from this group -- thanks!). The people I was working with have a site that uses lots of php objects. They are having problems with speed. They had a vague idea that PHP5 has improved handling of objects over PHP4, so it would probably be faster also. In fact it seems slower. We did a few timing loops, in which a a number of objects were created and and members were...
1
2067
by: | last post by:
I just ran this stuff for my own knowledge. Though it might be useful to some other people to know and maybe spark a discussion. I needed a fast way to test for membership, so naturally the choices were the builtin containers: lists, dictionaries, and tuples. The following is the test code and results: import timeit lst_i=timeit.Timer('random.randrange(10000) in l','import
7
1545
by: borges2003xx | last post by:
hi everyone can someone suggest me where find a lot programming tricks for achieving the top speed in python? thanks everyone for patience
2
1298
by: Cat | last post by:
When I download a file from internet, using whether WebRequest or WebClient, it is downloaded at the maximum line speed. But I would like to let the users decide the maximum download speed just like eMule(you know eMule, don't you?) does. How can I do this? Plus, is it possible to be notified when the system gets connected to the internet or disconnected from the internet? Should I use Windows API or is there a .NET way? Thank you.
1
10409
by: chankey | last post by:
I have code that is able to print using the PrintDocument class, PrintPage event and the Graphics.DrawString method. It is on the slow side though. Does anyone have an ideas on how to speed up the printing process? I did read one suggestion that said I should use the Win32 API's for printing, but that is too much work for the info I want to print.
35
2737
by: fermineutron | last post by:
For a while now i have been "playing" with a little C program to compute the factorial of large numbers. Currently it takes aboy 1 second per 1000 multiplications, that is 25000P1000 will take about a second. It will be longer for 50000P1000 as expected, since more digits will be in the answer. Now, on the Num Analyses forum/Group there is a post reaporting that that person wrot java code that computed 1000000! in about a second. That is...
17
1991
by: garrickp | last post by:
While creating a log parser for fairly large logs, we have run into an issue where the time to process was relatively unacceptable (upwards of 5 minutes for 1-2 million lines of logs). In contrast, using the Linux tool grep would complete the same search in a matter of seconds. The search we used was a regex of 6 elements "or"ed together, with an exclusionary set of ~3 elements. Due to the size of the files, we decided to run these line...
8
2457
by: mast2as | last post by:
I am sure this topic has been discussed a thousand times and I read a few things about it today on the net. I also want to say I am trying to start a polemic here, I am just curious and willint to learn and improve the way I am approaching some coding issues that I have at the moment. I use C++ programming for my work, but I am not a developper so please be patient & tolerant in your answers ;-) Okay for the last few days I have been...
0
3037
by: raylopez99 | last post by:
Hi, I'm getting into GDI+ Forms 2.0 graphics for C#3 using Visual Studio 2008. One thing I notice: the graphics are really slow and flicker on a Pentium IV, with 2 GB RAM, even with doublebuffering turned on. I did learn tricks such as not invalidating everything, but just the control that is part of the form you are working on (i.e.,
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.