My first experience with Cfthread tag, I had to loop through a query with loads of records. To make the looping faster, I used 10 cfthreads, below is how to do it.
<cfquery name="get_data" datasource="whatever">
select xyz from table
</cfquery>
First create 10 threads
<cfloop index="intGet" from="0" to="9" step="1">
<cfthread action="run" name="objGet#intGet#">
do some calculations to get the startrow and endrow for each thread to loop through
<cfset startRow = int((#intGet# * #get_users.Recordcount# / 10) + 1)>
<cfset endRow = int(((#intGet# + 1) * #get_users.Recordcount# / 10))>
Loop through the query
<cfloop query="get_data" startrow="#startRow#" endrow="#endRow#">
-------- Your calculations / stuff goes here -------------
</cfloop>
</cfthread>
</cfloop>
Lastly JOIN the threads
<cfloop index="intGet" from="0" to="9" step="1">
<cfthread action="join" name="objGet#intGet#" />
</cfloop>
you would be able to save a lot of time, also you can use "thread" scopes to assign values and then do the calculations.
Thursday, March 26, 2009
Subscribe to:
Post Comments (Atom)
Blog Archive
-
►
2007
(18)
-
►
July
(8)
- Searching on Google, Really Cool stuff !!!!!
- Jazz, Two Months Old !!!!!!
- FRIENDS All Seasons Download Links !!!!!!!!
- Output Query To CSV file using Coldfusion MX and J...
- How to Parse XML using Coldfusion MX
- How to Output Query In Excel Format Using Coldfusi...
- SQL Server Interview Questions
- ASP.Net Interview Questions
-
►
July
(8)
1 comments:
I found this site using [url=http://google.com]google.com[/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!
Sorry for offtopic
Post a Comment