Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cfdirectory very slow

Guest
May 25, 2007 May 25, 2007
Hi guys,

We have a issue with any page that use cfdirectory. The page are really slow, and on two different servers.. (win 2003, MX 7)

we have a lot of files, by the problem appeared suddently...

Any idea?

thanks!
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2007 May 25, 2007
> the problem appeared suddently...

What changed in your environment just before it started?

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 28, 2007 May 28, 2007
Thanks for your replies,
It seams the number of files went to 18000. Now it's back at 3000. So instead of 2 minutes, it takes 15 seconds (still quite slow). Anybody knows how to speed it up?

I use a tag called "dirlist.cfm" (written by Rizal Firmansyah, 2001). I had to modify it to work with MX. Maybe there's a better one.. Thanks..(here's the code:

<cfsetting enablecfoutputonly="yes">

<!--- check and setup parameters --->
<cfparam name="attributes.filter" default="*.*">
<cfparam name="attributes.sort" default="">
<cfset dirs=attributes.Directory>
<cfset Name=attributes.Name>
<cfif not isdefined("caller.#Name#")>
<cfset "caller.#Name#"="">
</cfif>

<!--- create query --->
<cfset TempResult=querynew("Name, Ext, Dir, Size, Type, DateLastModified, Attributes, Mode")>

<!--- loop through directories --->
<cfloop condition="listlen(dirs) gt 0">
<cfset CurrDir=listfirst(dirs)>
<cfloop list="#attributes.filter#" index="CurrFilter">
<!--- <cfdirectory action="LIST" directory="#CurrDir#" name="DirResult" filter="#CurrFilter#" sort="#attributes.sort#"> --->
<cfdirectory action="LIST" directory="#CurrDir#" name="DirResult" sort="#attributes.sort#">
<cfloop query="DirResult">
<cfif ((Type is "Dir") and (Name neq ".") and (Name neq "..")) or
(Type is "File")>
<cfif queryaddrow(TempResult)>
<cfset dummy=querysetcell(TempResult,"Name",Name)>
<cfif (Type is "File") and (Name contains ".")>
<cfset dummy=querysetcell(TempResult,"Ext",reverse(listfirst(reverse(Name),".")))>
<cfelse>
<cfset dummy=querysetcell(TempResult,"Ext","")>
</cfif>
<cfset dummy=querysetcell(TempResult,"Dir",CurrDir)>
<cfset dummy=querysetcell(TempResult,"Size",Size)>
<cfset dummy=querysetcell(TempResult,"Type",Type)>
<cfset dummy=querysetcell(TempResult,"DateLastModified",DateLastModified)>
<cfset dummy=querysetcell(TempResult,"Attributes",Attributes)>
<cfset dummy=querysetcell(TempResult,"Mode",Mode)>
</cfif>

<!--- add directories found to search list --->
<cfif (Type is "Dir")>
<cfset Dirs=listappend(Dirs,"#CurrDir#\#Name#")>
</cfif>
</cfif>
</cfloop>
</cfloop>
<cfset Dirs=listdeleteat(Dirs,1)>
</cfloop>

<!--- pass result to calling templates --->
<cfset "caller.#Attributes.Name#"=TempResult>

<cfsetting enablecfoutputonly="no">
Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 29, 2007 May 29, 2007
CFDirectory does tend to be very slow, particularly once you have any number of files for it to handle. I find the java libraries work far better if all you need is a list of files and directory names. Here's example code:

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 28, 2007 May 28, 2007
> Anybody knows how to
> speed it up?

Yep: organise your files better. Even 3000 files in a dir is a nasty
number to have. Windows "file management" (such as it is), begins to
struggle when there more than a few hundred files in a dir.

Why have you got 3000-18000 files in one single directory?

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 29, 2007 May 29, 2007
I have a lot of files since it's a content management system. So I can't really organise them.

And thanks for the java code, I'll check that out closely.

Have a nice day..
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007
LATEST
> I have a lot of files since it's a content management system. So I can't really organise them.

That's a bit of a non sequitur. Why can you not manage the files with your
CMS? Or is it someone else's CMS, and "that's just the way it works"?

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2007 May 27, 2007
Test whether cfdirectory is indeed the cause. Compare the execution time of the cfdirectory code block with that of the entire page.

<cfset beginTiming = getTickCount()>
<!--- cfdirectory code block --->
<cfset endTiming = getTickCount()>
cfdirectory block execution time: <cfoutput>#endTiming - beginTiming#</cfoutput> ms

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources