If you are only pulling one file back, why are you using CFDIRECTORY at all?
You already know the filename, so you can just use fileExists() to check if
it's there, and CFFILE to read it in if you need the contents.
  -----Original Message-----
  From: Nelson Winters [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, October 21, 2003 10:24 AM
  To: CF-Talk
  Subject: cfdirectory = slow

  Where do I report issues with CFMX to Macromedia?  I know I'm not the
first
  to discover this, but cfdirectory is extremely inefficient when dealing
with
  large directories.  I don't know if this is a problem with J2EE platform
  that CFMX runs on top of or what, but it shouldn't take several seconds to
  do a cfdirectory where I'm pulling only one file back, even if the
directory
  has a 100,000+ files in it.   It seems like cfdirectory loads the entire
  directory contents into memory and then applies the filter.

  Below is some sample code if anyone wants to see what I'm talking about.

  -Nelson

  <!--- Create a bunch of files --->
  <cfset vDir = "d:\test">
  <cfset NumberOfFilesToCreate = 100000>

  <cfif NOT DirectoryExists(vDir)>
      <cfdirectory action="" directory="#vDir#">
  </cfif>

  <cfloop from="1" to="#NumberOfFilesToCreate#" index="i">
  <cffile action="" file="#vDir#\z#i#.txt" output="This is file number
  #i#.">
  </cfloop>

  <!--- Get File Info --->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <html>
  <body>
  <cfset start = GetTickCount()>
  <cfset tmp = Randomize(right(start, 8))>
  <cfset fileIndex = RandRange(1, 1000000)>
  <cfif FileExists("#vDir#\z#fileIndex#.txt")>
  <cfdirectory action="" directory="#vDir#" name="dirTest"
  filter="z#fileIndex#.txt" >
  <cfdump var="#dirTest#">
  <cfoutput>@#fileContents#@</cfoutput>
  <cfelse>
  <cfoutput>File not found.</cfoutput>
  </cfif>
  <hr>Processing Time: <cfoutput>#GetTickCount()-Start#</cfoutput>
  </body>
  </html>



[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to