Re: Roundtrips!

Tech-Archive recommends: Speed Up your PC by fixing your registry



Arpan wrote:
> Well I am doing it in the simplest way........something like this:
>
> <%
> Dim objConn
> Set objConn=Server.CreateObject("ADODB.CONNECTION")
> 'ConnectionString
> objConn.Open
>
> Dim objRS
> Set objRS=Server.CreateObject("ADODB.RECORDSET")
>
> Dim strSQL
> strSQL="SELECT * FROM MyTable"

Hopefully this was an example only and you really aren't using selstar in
your production code. If you're really interested in reducing round trips,
you will avoid the use of "Select *".

> objRS.Open strSQL,objConn
>
> 'all 100 records are populated in this Recordset
> %>
>
> That's it!
>
> What I mean to ask is is it something like to get the 1st record, ASP
> goes to the database which makes it 1 trip, reads it & comes back thus
> making it 2 trips. So for fetching all the 100 records, 100*2=200
> trips are involved in the process. Is it something like that?
>
Since you are using the default forwardonly cursor, then yes, something like
this will be happening. Fortunately, since a "firehose" cursor is being
used, it will be extremely efficient. You can reduce the mumber of trips to
the database by increasing the recordset's CacheSize property, which
defaults to 1 (record).

Different cursortypes will result in different behavior. For example, a
client-side cursor (which will always be a static cursor) will always
retrieve all its records in a single round trip to the database. You will
need to weigh the benefits of the fewer round trips against the penalties of
increased resource usage on the web server. Factors involved in your
decision about what cursor type to use include:
desired functionality - e.g., do you need MovePrevious functionality?
number of records to be retrieved
size of the records to be retrieved

There is no magic answer here: you need to evaluate this on a case-by-case
basis.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: Cursors - Server Side - Only Forward?
    ... You're using VB's ADO.Recordset object to manipulate the cursor data. ... Using server side cursors would ... > Dim Dbs As New ADODB.Connection ... > ' Prepare SQL Select statement ...
    (microsoft.public.sqlserver.programming)
  • Re: Count number of Records Query always returns -1
    ... My total code is:- ... Dim MyVar As Boolean ... Set cnn = CurrentProject.Connection ... Others say that as long as you use a clientside cursor, it's OK, or use ...
    (microsoft.public.access.queries)
  • Re: "IsInField" method?
    ... Dim myrange As Range ... Dim Flag As Boolean ... For Each afield In ActiveDocument.Fields ... If the cursor is in a field, ...
    (microsoft.public.word.vba.general)
  • Re: Blink a cursor in the selected bookmark
    ... Dim wa As New Word.Application ... word "Section1" on the particular bookmark. ... UpOn Clicking on Section 1 Button1, it should display cursor on the right ...
    (microsoft.public.word.vba.general)