Friday, February 03, 2012    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Nov 2006 >>
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Search

Categories
 • Acrobat (5) [RSS]
 • Adobe (110) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (66) [RSS]
 • AdobeMAX09 (39) [RSS]
 • AdobeMAX10 (34) [RSS]
 • AdobeMAX11 (27) [RSS]
 • AIR (297) [RSS]
 • Appearances (217) [RSS]
 • Books (86) [RSS]
 • CFEclipse (15) [RSS]
 • Cloud (1) [RSS]
 • ColdFusion (1477) [RSS]
 • ColdFusion Builder (22) [RSS]
 • Data Services (42) [RSS]
 • Fish Tank (5) [RSS]
 • Flash (356) [RSS]
 • Flex (561) [RSS]
 • Home Automation (5) [RSS]
 • HTML5 (21) [RSS]
 • JavaScript (2) [RSS]
 • Jobs (130) [RSS]
 • jQuery (14) [RSS]
 • JRun (14) [RSS]
 • Labs (62) [RSS]
 • LiveCycle (37) [RSS]
 • MAX (284) [RSS]
 • Mobile (238) [RSS]
 • Regular Expressions (19) [RSS]
 • RIA (21) [RSS]
 • SQL (45) [RSS]
 • Stuff (554) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (167) [RSS]

Other BLOGs
 • Charlie Arehart
 • Lee Brimelow
 • Ray Camden
 • Christophe Coenraets
 • Sean Corfield
 • Mihai Corlan
 • Cornel Creanga
 • Mark Doherty
 • John Dowdell
 • Danny Dura
 • Enrique Duvos
 • Steven Erat
 • Kevin Hoyt
 • Serge Jespers
 • Adam Lehman
 • Duane Nickull
 • Miti Pricope
 • Andrew Shorten
 • Ryan Stewart
 • James Ward
 • Greg Wilson
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Entry / Main
November 1, 2006

Improving <CFDIRECTORY> Performance

Mark Kruger posted comments about the performance of <CFDIRECTORY ACTION="list"> (see post 1 and post 2). He noted that returning full directory information with all file details (especially over network connections) can be painfully slow. As per his post, using Java APIs to return directory lists is far quicker, which is odd as <CFDIRECTORY ACTION="list"> actually uses the same Java APIs internally.

In a comment on Mark's blog, Tom Jordahl pointed out that the reason for this is that for <CFDIRECTORY> to return all file details it needs to first retrieve the file list and then perform a Java stat() for each file, and that stat() call is very time consuming (especially over network connections). The solution, if you just need file names and not other details, is to use the undocumented LISTINFO attribute. LISTINFO defaults to "all", but specify LISTINFO="name" and <CFDIRECTORY> will only return file names and will run just as quickly as the Java APIs it relies on.

Comments
This can be done on all versions of CFMX?
# Posted By Andrea Veggiani | 11/2/06 4:52 AM
Hi,
Any chance of this being added to the documentation?

Cheers,
Tony
# Posted By Anthony Batchelor | 11/2/06 6:35 AM
Andrea, I don't know about CFMX, it is definitley in CFMX7.

Anthony, yes, it'll be added, and is already in a note at the bottom of that page in LiveDocs.

--- Ben
# Posted By Ben Forta | 11/2/06 9:34 AM
Does the listinfo attribute take a list of columns to return? If so, what columns can be returned w/out the stat() call being invoked?
# Posted By Dan G. Switzer, II | 11/2/06 11:14 AM
Dan,

Right now it is NAME or ALL, as far as I know.

--- Ben
# Posted By Ben Forta | 11/2/06 11:20 AM
I tested and this does not work on CFMX 6.1, only 7. Also, it looks like the only valid values are NAME and ALL. (Anything other than name appears to give you all the info.) It would be nice if you could include a list of columns as Dan suggests.
# Posted By Nathan Mische | 11/2/06 12:55 PM
Well hopefully the cf team will add the other parameters to scorpio. It would be nice to give multiple parameters like name and size or something like that. Also a expanded filter would nice, eg <cfdirectory name="getImages" folder="C:\images" filter=" *.jpg | *.gif | *.png " />

I'm not thinking any of this will be released in any hotfix... Or maybe they will... Ben??

btw, you got some comment spam up here...
# Posted By Michael | 11/26/06 12:21 AM
Yes I have great interest in knowing if the filter attribute in cfdirectory will be expanded as Michael has suggested. For example, I currently use cfdirectory to automate some things in my application for me such as initializing my controllers (use cfdirectory to read and list my controllers directory) and initializing my models (simply reads the models directory). With that approach I'd like to do a little bit more with the filter other than *.cfc so I can filter out specific files, for example those that start with an underscore "_" or some familiar set of letters. Thanks though for this great post! All I've needed is to the name of the file and no other data so its nice to know I can speed it up now using the listinfo attribute. Thanks for sharing with us Ben!
# Posted By Javier Julio | 12/3/06 8:12 PM
Is there anyway that I can get just the NAME and DATELASTMODIFIED from cfdirectory?
Thanks
CJ
# Posted By CJ | 1/26/07 10:04 AM
I have discovered that the use of the sort attribute of CFDirectory is a significant contributor to it's poor response with large file lists (CFMX 6.1).

If you need to sort a large CFDirectory listing, you may find a very significant improvement if you...

- CFDirectory but do NOT use the sort attribute.
- Do a Query of Query on the CFDirectory results and sort within the Q of Q.
- Do not use SELECT * in the Q of Q. Only select the fields you need such as the file Name and Date.
- If you need to filter the results, it can be done in the same Q of Q.

Be sure to test both ways and see which is better. (We had a 10 times faster response in one case.)

(Reminder: CFDirectory results are stored as a Query object in memory.)

The above is a "CF only" workaround using documented calls (as compared to some of the known JAVA workarounds).

Hope This helps some folks!

Bruce L. Jacobs

“The comments and opinions expressed are my own
and do not represent the views of United Space Alliance.”
# Posted By Bruce L. Jacobs | 5/1/07 4:11 PM
Thanks though for this great post! All I've needed is to the name of the file and no other data so its nice to know I can speed it up now using the listinfo attribute.Anything other than name appears to give you all the info
# Posted By Alex | 12/22/07 7:53 AM
Was just curious what all parameter LISTINFO could have that are as useful as this "name". By now, I am sure this is in documented info

---
Abhijeet
http://www.lifeiscolourful.com
# Posted By Abhijeet | 7/12/08 4:15 AM
Wow, that's a good number of spam comments from various people. I am not sure if Ben is busy or something else, but I never saw this happening few months back
# Posted By Techie Traveler | 11/21/08 11:17 AM

  © Copyright 1997-2009 Ben Forta, All Rights Reserved