Skip to main content
Inspiring
July 1, 2006
Answered

Storage of the dynaset

Question: When you retrieve records and build a list of data is the data stored in a dynaset that can be referenced? ie: Say I get all records from a database that begin with the letter "a" and then populate a page with a list of that data. Once the page is built, is that data still stored in something like a temporary table where it can still be access without doing another SQL select?
    This topic is closed to new replies. Start a new post to keep the conversation going.
    JaredJBlackburnCorrect answer
    Inspiring
    July 3, 2006
    Caching the query or storing the resulting query object/structure in a persistent scope ( <cfquery name="application.myQuery"...>) should give the results that you seem to be looking for. Which users will need access to a particular object, in this case a query object, should dictate which persistent scope you should use session/application/server. Session is the most popular, but not always to the best. If, for instance, many users would be using the data retrieved by the same query, then it would be best executed once and its results stored in the application scope for all to use rather than executed and stored multiple times so that each user has a copy in their session scope.

    Also, be aware of if and when the data should be refreshed by rerunning the query on the database and overwriting the previously stored results with the fresh ones. And finally, on a site with many concurrent users, you should always be mindful of your memory constraints - especially when storing large datasets in persistent scopes for each user. Data can be removed from persistent scopes using structDelete().

    5 replies

    Inspiring
    July 1, 2006
    ghouser,
    You can 'cache' the query results for a quicker response the next time around on the same page, but in answer to whether the query results can be referenced from the server as a 'session' type query result. No. Unless you save it as a Session variables, it won't be accessible and you will have to repeat the query.

    Hope this helps
    Translate
    ghouserAuthor
    Inspiring
    July 1, 2006
    I should have elaborated. I retrieve records from the db and create a page of the records. The first field is a link that pops up an item detail page on that record in a new window, the parent stays behind. What I'm hoping to do is build in buttons that allow you to browse forward and backward in the item detail window based on the records listed in the parent page. I hope that explains it better.
    Translate
    JaredJBlackburnCorrect answer
    Inspiring
    July 3, 2006
    Caching the query or storing the resulting query object/structure in a persistent scope ( <cfquery name="application.myQuery"...>) should give the results that you seem to be looking for. Which users will need access to a particular object, in this case a query object, should dictate which persistent scope you should use session/application/server. Session is the most popular, but not always to the best. If, for instance, many users would be using the data retrieved by the same query, then it would be best executed once and its results stored in the application scope for all to use rather than executed and stored multiple times so that each user has a copy in their session scope.

    Also, be aware of if and when the data should be refreshed by rerunning the query on the database and overwriting the previously stored results with the fresh ones. And finally, on a site with many concurrent users, you should always be mindful of your memory constraints - especially when storing large datasets in persistent scopes for each user. Data can be removed from persistent scopes using structDelete().
    Translate
    ghouserAuthor
    Inspiring
    July 3, 2006
    Jared,

    Awesome answer, it looks like what I needed.... at that time. Since then I went a different way with the application and am not using that method. However, it will come in handy for another project coming up. I also did more reading on "session scope" which helped a bunch.

    You guys are all great to help the way you do. Thanks a bunch!
    Translate
    July 1, 2006
    The results of the CFQUERY hangs around until the page ends. For example:
    Translate