CFScript query alot slower than CFML!
Has anyone experienced CFScript addParams being much slower
than CFML <cfqueryparam>?
In my test, CFML took 2 min. to insert 20,000 rows.
But, CFScript took 27 min!
Here is basically what I'm trying to do:
----------------------- CFScript ----------------------------------------------
var myquery = new query(dataSource="...",
sql="insert into mytable (col1, col2, ..., col64)
values (:col1, :col2, ..., :col64)");
var i = 1;
while (i <= #recs.q.recordCount#) {
myquery.clearParams();
myquery.addParam(name="col1", null="#recs.n['col1']#", value="#recs.q['col1']#", cfsqltype="cf_sql_varchar");
myquery.addParam(name="col2", null="#recs.n['col2']#", value="#recs.q['col2']#", cfsqltype="cf_sql_varchar");
...
myquery.addParam(name="col64", null="#recs.n['col64']#", value="#recs.q['col64']#", cfsqltype="cf_sql_varchar");
myquery.execute();
i = i + 1;
}
----------------------- CFML --------------------------------------------------
<cfset var i = 1>
<cfoutput query="recs.q">
<cfquery name="myquery" dataSource="...">
insert into mytable (col1, col2, ..., col64)
values (<cfqueryparam null="#recs.n['col1']#" value="#recs.q['col1']#" cfsqltype="cf_sql_varchar">,
<cfqueryparam null="#recs.n['col2']#" value="#recs.q['col2']#" cfsqltype="cf_sql_varchar">,
...
<cfqueryparam null="#recs.n['col64']#" value="#recs.q['col64']#" cfsqltype="cf_sql_varchar">)
</cfquery>
<cfset i = i + 1>
</cfoutput>
-------------------------------------------------------------------------------
In the CFScript version, I thought clearing and re-adding the params on each
iteration might be the problem. So, as a test, I removed the clearParams(),
and moved the addParams before the loop, calling them just once
(adding the same param values over and over, which of course is not what
I really want to do). But, it's just as slow.
I might also point out that both versions are huge memory hogs
(the CFScript version is worse), and the memory never seems to get
garbage collected after my script is done.
Anyone have any ideas?
Thanks.
myscreenname0345
