Thread: Logic Question

    #1
  1. Some day I will be a Lambda!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    NJ
    Posts
    18
    Rep Power
    0

    Question Logic Question


    Here is a question that I have been thinking about and maybe someone out there can help me out.

    Is it faster to loop through a query looking for a specific value or to send new queries asking for only the specific value.


    Code:
    Array as some array
    
        submit SQL in query object
    
        do until end of Array{
            do until query = Array{
                move to next query
            }
            move to next Array
            do something with query
        }
    OR

    Code:
    Array as some array
    
        do until end of Array{
            SQL = Array
            submit SQL in query object
            move to next Array
            do something with query
        }
    Thanks

    Eric
  2. #2
  3. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    32
    >Is it faster to loop through a query looking for a specific value or to send new queries asking for only the specific value.
    This, along with your pseudo code, doesn't make whole lot of sense. Could you explain in plain english what you want?
    And you know I mean that.
  4. #3
  5. No Profile Picture
    i do computer stuff
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    1
    Rep Power
    0

    Usually, less DB access is better


    DB Access is generally one of the slowest part of an app. A frequently successful strategy is to cache a large query with many records and use app code to retrieve desired specific records from that query. Of course, if your recordset is potentially huge (many megabytes) then you might have memory issues.

    In general, I would say it is faster to loop through a large query looking for the values you want than to execute many small queries. Of course, be careful that you don't end up looping through 20000 records.

    Hope this helps!
  6. #4
  7. Some day I will be a Lambda!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    NJ
    Posts
    18
    Rep Power
    0

    Wink


    Thanks,

    That's what I thought. I just wanted to make sure.

    Eric

IMN logo majestic logo threadwatch logo seochat tools logo