Thanks, but I solved it completely differently by re-coding my original
query. I was looping thru the query to run a separate query and sticking the
results of the second query in a structure (since I needed a list of
associated values for each record in the main query). This was mega-slow,
since there are now 850+ records in the main query, which means 850+ small
queries.

I finally realized I could do the same thing using "order by" and "cfoutput
group". I don't know why it took me so long!!! I was banging my head against
the wall trying to come up with a clever way to replicate the Sybase LIST()
function in MS SQL (which may be impossible given my DB design).

Now the big query takes about 200ms longer, but I've cut out about 10
seconds not doing the many small queries.

Thanks - Eric

-----Original Message-----
From: Philip Arnold - ASP [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 09, 2001 1:44 AM
To: CF-Talk
Subject: RE: Performance Tests


> So if I need to loop over the contents of one column of a large
> query, which would be faster:
>
> <cfloop query="big_query">
> ...do stuff with #column1#...
> </cfloop>
>
> <cfloop list="#ValueList(big_query.column1)#" index="i">
> ....do stuff with #i#...
> </cfloop>
>
> <cfset myarray=ListToArray(ValueList(big_query.column1))>
> <cfloop index="i" from="1" to="#ArrayLen(myarray)#">
> ....do stuff with myarray[#i#]...
> </cfloop>
>
> this needs to be a <cfloop> since I'm using tags in it.

Looping over lists, and list functions are always slower than referring
directly to an array or a query

There is another alternative;
If you're not doing a CFOutput

<cfscript>
for (i=1; i lte big_query.recordCount; i=i+1)
{       do stuff with big_query.Column1[i];
}
</cfscript>

or if you need CFOutput

<cfloop index="i" from=1 to="#big_query.recordCount#">
        do stuff with big_query.Column1[i]
</cfloop>

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to