the easy solution is to create the query in the session scope to begin with
<cfquery name="session.myquery"> however storing complex vars such as queries in sessions for every single user can consume a lot of memory. If the contents of the query are not unique to each user, you could just cache one copy in application scope. The other alternative is to cache the entire dataset you need to store on in application scope and use query of query for each user to get their subset of data. If storing the query in the session is a must, you may want to try converting it to JSON or WDDX and see how much memory this uses compared to the query. Don;t forget not to select columns you don't need. On Thu, Mar 24, 2011 at 8:48 PM, Carl Von Stetten <[email protected]>wrote: > > Wow, I finally got it!!! :-) > Thanks, > Carl > > On 3/24/2011 1:27 PM, Brian Kotek wrote: > > That's correct. > > > > On Thu, Mar 24, 2011 at 4:18 PM, Carl Von Stetten > > <[email protected]>wrote: > > > >> I'm trying to wrap my head around this, so please excuse me for jumping > >> in. If I understand this correctly, the query result is an object > >> placed in memory when execution is complete, and variables.qry is merely > >> a pointer to that object. When the<cfset session.myQry = > >> variables.qry> is executed, a second pointer to the query object is > >> created, in the session scope. When page execution completes, the > >> variables.qry pointer disappears (and I assume is garbage collected at > >> some point), but because the session.myQry pointer still exists in the > >> session scope, the query object remains in memory instead of being > >> garbage collected. Once the session times out, assuming there are no > >> other pointers to the query object existing, it would then be garbage > >> collected. > >> > >> Is this a correct understanding, or am I completely off my rocker? > >> Thanks, > >> Carl > >> > >> On 3/24/2011 12:59 PM, Brian Kotek wrote: > >>> All complex data types are always passed by reference. Where you set > them > >>> makes no difference. (Except arrays, which are passed by value due to a > >>> staggeringly poor decision eons ago.) > >>> > >>> > >>> On Thu, Mar 24, 2011 at 3:49 PM, Eric Cobb<[email protected]> > wrote: > >>> > >>>> I know that complex data types (structs, CFCs, queries, > COM/JavaObjects, > >>>> etc...) are passed by reference, not by value. But I'm wondering how > >>>> that works when storing them in the session scope. > >>>> > >>>> For example, let's say I have a query that returns a really large > result > >>>> set, and after that query runs I store the query results as a variable > >>>> in the session scope. > >>>> > >>>> <cfquery name="variables.qry"> > >>>> select * > >>>> FROM bigTable > >>>> </cfquery> > >>>> > >>>> <cfset session.myQry = variables.qry> > >>>> > >>>> Would the above code just create a reference to the result set already > >>>> in memory, or would it actually create a copy of the results in the > >>>> session? > >>>> In a similar scenario, what would happen if I had a CFC object stored > in > >>>> the session, then passed my query results to it to be stored in that > >>>> CFCs "variables" scope? > >>>> > >>>> <cfquery name="variables.qry"> > >>>> select * > >>>> FROM bigTable > >>>> </cfquery> > >>>> > >>>> <cfset session.myCFC.blah(variables.qry)> > >>>> > >>>> -- > >>>> > >>>> Thanks, > >>>> > >>>> Eric Cobb > >>>> http://www.cfgears.com > >>>> Help me make a difference this summer. http://bit.ly/i8dJvQ > >>>> > >>>> > >>>> > >>>> > >>>> > >> > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343258 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

