Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old December 11th, 2002, 05:16 PM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
  #2  
Old December 11th, 2002, 05:21 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Corporal (100 - 500 Reputation Level)AlCapone User rank is Corporal (100 - 500 Reputation Level)AlCapone User rank is Corporal (100 - 500 Reputation Level)AlCapone User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 13
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
>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.

Reply With Quote
  #3  
Old December 11th, 2002, 06:24 PM
avi4now avi4now is offline
i do computer stuff
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 1 avi4now User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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!

Reply With Quote
  #4  
Old December 12th, 2002, 06:21 AM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink

Thanks,

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

Eric

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Logic Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway