OK, we'll let that path go (the discussion of CFQUERYPARAM).
But you say, "The page does not load - and always crashes on a
timing error after 60 seconds. If I immediately run it again if
loads properly within a few seconds. If I cut and paste the query
to a SQL editor, the query runs in less than 4 secs. Obviously this
must be some kind of CF Administrator issue..."
Well, I still wouldn't jump to that conclusion. I mean, you
say that the first execution was slow, but then a refresh of the
page makes it run fast. That just sounds like it took time for
Oracle to compile the query and then find and load that data (into
its cache) and pass it back to CF. The fact that it ran fast the
2nd time would seem to confirm this, as does your running the query
in Oracle directly. Each of those could be re-running the execution
plan created the first time, and may be pulling records from
Oracle's buffers.
One way to confirm this is to change the SQL (run in Oracle
directly) to get some other columns. That will cause Oracle to
compile the SQL statement. Maybe also change the Where clause to
cause it to get different records (so it loads different data into
Oracle's buffers). Does that query then take "longer"? If so, if
you run the same code in CF (after that), does it run "faster"? If
so, this would confirm these suspicions.
I realize this may not be it, but it seems worth ruling out.
Things aren't usually totally mysterious.
There are also ways you can ask the DBMS to report the
execution plan and statistics about creating and running the query,
from the DB side, though those aren't always easily available from
CFML. Indeed, the tool I'd recommend for such a case in SQL Server
is SQL Server Profiler, which allows you to watch what queries come
into SQL Server from CF (among other things) and shows considerable
detail. I would imagine there are tools like that for Oracle, too.
It may pay to know more about that it things about these queries
if/when they run slowly.
Hope that's helpful.
/Charlie (troubleshooter, carehart. org)