Michael, Any chance you can give us a real example and some more detail so we may try to give you the best solution?
On Wed, Jul 14, 2010 at 10:54 AM, DURETTE, STEVEN J (ATTASIAIT) < [email protected]> wrote: > > Correct me if I'm wrong (please) but isn't a query already a Struct of > Arrays? > > I mean the following is totally valid: > > Table user_list (user_fname, user_lname) {shown in comma delimited format} > Cameron, Childress > Michael, Dinowitz > Steve, Durette > > <cfquery name="myUserList" (blah blah) > > Select user_id, user_name > From user_list; > </cfquery> > > <cfoutput> > #Variables.myUserList["user_fname"][2] # > </cfoutput> > > Would output: Michael > > So after the query is loaded, you can just use the data. No copying no > extra query, just direct access. > > Steve > > -----Original Message----- > From: Cameron Childress [mailto:[email protected]] > Sent: Wednesday, July 14, 2010 10:27 AM > To: cf-talk > Subject: Re: struct lookup vs. query of queries > > > On Tue, Jul 13, 2010 at 12:19 PM, Michael Dinowitz > <[email protected]> wrote: > > I've got a loop which will need to look up a piece of data on each > > iteration. The data is standardized so there is really just one call > > to the database (outside the loop). I can either do a query of queries > > on each iteration or I can turn the query into a structure and do a > > structure lookup (structkeyexists, etc) on each iteration. I'm > > assuming that the struct lookup will be faster/more efficient even > > after having to turn the query into a structure. > > Anyone have an opinion on this? > > I virtually always choose to use a struct in these cases. There are > very few cases where I have seen an argument to use QoQ for virtually > anything. QoQ is typically much slower than structs, assuming you are > using alot of values from the query. Sometimes it can even be faster > to go back to the DB each time rather than QoQ. Seriously. > > Depending on the use case, I like to convert the Query to a struct and > then cache that struct either in a shared scope, or using CF9's > EHCache caching mechanisms. You can wrap that whole thing up in a > nice little CFC and it become really quite reusable. > > -Cameron > > -- > Cameron Childress > Sumo Consulting Inc > http://www.sumoc.com > --- > cell: 678.637.5072 > aim: cameroncf > email: camer...@gmail. > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335368 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

