Results 1 to 3 of 3

Thread: Which way is better (arrays & db)

  1. #1

    Thread Starter
    Hyperactive Member davem's Avatar
    Join Date
    Dec 2000
    Location
    Gainesville, FL
    Posts
    265

    Unhappy

    I use an SQL query to get certain records from my database (using DAO w/ jet). Then I copy the data returned into a user-defined type array.

    For example:
    My database contains these columns...
    Code:
    "Name", "Age", "Height", "Weight", "Sex"
    I define my user-defined type:
    Code:
      Type myType
        Name as String
        Age as Integer
        Height as Double
        Weight as Double
        Sex as String
      End Type
    Thus the "Name" column would be assigned to myType(1).Name for example.

    I have a lot of columns (approx 20) in my real project. I also have about 9,000 records. To make things faster I chose to only "pull" data out of five columns (instead of all twenty) and assign them to my array.

    THE QUESTION: (finally!) would there be a large speed/memory usage differential if I just dumped all 20 columns into my array (so I could work with all the values at my leisure?). Note, as of right now I use the data I got (the five columns) to access the database again (later on) to get any other info I need (say the user's "Origin for example).

    To sum up, I know that getting all the records right off the bat would be faster and just to give you an idea of my data, the other 15 columns are basically double precision numbers or booleans. I just wanted to get an expert opinion.

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Hi davem

    you are right in saying that it would be quicker to get them on the fly but you could also make a class to handle all the database work, then a collection of the class to store each record.

    Hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    The way to answer this question is to examine the whole process. What is the sloweset thing you are doing? A. Accessing your db (v. slow). Storing and retrieving data in memory is quick (unless you use virtual memory). So optimise your data fetch.

    Ensure that you only get the data you really need to transfer (i.e. limit the columns and limit the number of records).

    Actual performance of an app is not the same as apparent performance. It may be quicker to fetch 9000 records than do twenty fetches of 450 records, but your users won't see it that way. If you can fetch data while the user is processing the first batch, so much the better.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width