I've got a page that is taking 12-15 seconds to load. It turns out the problem is the <cfdirectory> tag. It's searching a folder with 2131 files to see which filenames match the primary key (Property_ID) for a property on a real estate site. The files are named with the primary key. Is there a way to optimize the file query to make it run faster? I've tried caching the query results in the CFQUERY tag and defining the fields in the select statement--neither helped.
Here's the code:
<CFDIRECTORY DIRECTORY="filepath" NAME="DirectoryQuery" SORT="Name ASC">
<CFQUERY DBTYPE="query" NAME="FilesQuery">
SELECT *
FROM DirectoryQuery
WHERE TYPE = 'File' AND NAME LIKE '#Property_ID#.%'</CFQUERY>
Here's the code:
<CFDIRECTORY DIRECTORY="filepath" NAME="DirectoryQuery" SORT="Name ASC">
<CFQUERY DBTYPE="query" NAME="FilesQuery">
SELECT *
FROM DirectoryQuery
WHERE TYPE = 'File' AND NAME LIKE '#Property_ID#.%'</CFQUERY>