SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Member ngaisteve1's Avatar
    Join Date
    May 2003
    Location
    Kuala Lumpur, Malaysia (Boleh!)
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    When to use getstring / getrows?

    I know that getstring or getrows increase performance but my question when to use this method. This is because what I know is this method will output all fields in a table and not just certain few.

    Thanks.

  2. #2
    SitePoint Zealot Imran-Saami's Avatar
    Join Date
    Sep 2004
    Location
    Pakistan-Dubai
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getRows Method gives All Recordset in a Two Dimensional Array. then u close the Recordset and use that Array in your rest of the programming in the page which is more faster than using RS("FieldName").value.

    Note: its only used when u want to dispaly data only,,, not when u need to add/update data to the RS...

  3. #3
    Phil fillup07's Avatar
    Join Date
    May 2002
    Location
    Jacksonville, FL
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is because what I know is this method will output all fields in a table and not just certain few.
    Definately not true.... just as with any other SQL SELECT statement, you can specify in the WHERE clause which records to pull specifically. ANYTHING you can do without GetRows for displaying data from the database, you can do with GetRows, and it should be faster with.

  4. #4
    Member ngaisteve1's Avatar
    Join Date
    May 2003
    Location
    Kuala Lumpur, Malaysia (Boleh!)
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks.

  5. #5
    SitePoint Zealot TheTank's Avatar
    Join Date
    May 2003
    Location
    Houston, TX
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, not only can you slim the results down by using the WHERE clause you can also keep from using SELECT * wherever possible. Only pull the fields you are working with.

    I use getrows every single time I call a recordset no matter what the size.
    I think sometimes I dream in code.

  6. #6
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like anything else, GetRows has its place and is useful in many situations to improve performance by retrieving the entire resultset in a single hit. Therefore, this is ideal for instances where you are retrieving large volumes of data (or accessing data which may grow over time), but since the amount of additional coding is significant, it makes little sense if you're pulling a small number of records, e.g. to create a 30 record dynamic SELECT element. In cases like the latter, you can set the Recordset.CacheSize to an appropriate size (before querying) to obtain close to the same performance as GetRows.

    Also remember that there are many circumstances when it is extremely useful to be able to use the Recordset's .Filter and .Find features to navigate around the resultset, which often avoids the need to requery the same table (because - somewhat counter-intuitively - you can retrieve a larger result set in the first hit and simply filter it as required). Doing the same with a plain array (as delivered by GetRows) would be not only complicated but also damn slow (not least because the native Recordset functions are optimized machine code rather than interpreted VBScript).

    So in summary, knowing when to use a given API feature (like GetRows/GetString/etc) and when not to really boils down to a question of experience and judgement - there are no hard and fast rules and you should decide for yourself whether one or more techniques are appropriate in a given scenario. At its simplest, it's a cost-benefit analysis exercise - weigh implementation cost with long term performance benefit, and if the latter is (close to) *negligible*, then there's simply no point.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

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