get Query MetaData (ExecutionTime)

178 views
Skip to first unread message

Juerg Anderegg

unread,
Sep 9, 2016, 4:35:09 AM9/9/16
to Lucee
I want to get the execution time of a query within my code.
In ACF, this was possible with 
<cfquery name="qTest">....</cfquery>
<cfset executionTime = qTest.getMetaData().getExtendedMetaData().executionTime />

In Lucee, I can do it with
<cfquery name="qTest" result="myQueryResult">....</cfquery>
<cfset executionTime = myQueryResult.executionTime />

(note the attribute "result" in the second query)

BUT... normally, I don't use the "result"-Attribute in my queries. Workflow is that I do a query in a model and then return the query itself (<cfreturn qTest />). In the caller code, it's not possible to access to "myQueryResult". that would be stored in another struct. But... If I do a cfdump within the caller code, the execution time IS displayed; so it has to be somewhere...?

Julian Halliwell

unread,
Sep 9, 2016, 8:46:23 AM9/9/16
to lu...@googlegroups.com
Try this:

<cfset executionTime = qTest.getExecutionTime() />

Julian Halliwell

unread,
Sep 9, 2016, 8:56:40 AM9/9/16
to lu...@googlegroups.com
Or even more simply:

<cfset executionTime = qTest.executionTime() />

The value will be in nanoseconds. Convert to millseconds with:

<cfset executionTime = ( qTest.executionTime()/1000000 ) />

On 9 September 2016 at 13:46, Julian Halliwell

Harry Klein

unread,
Sep 13, 2016, 6:16:28 AM9/13/16
to Lucee

--
Get 10% off of the regular price for this years CFCamp in Munich, Germany (Oct. 20th & 21st) with the Lucee discount code Lucee@cfcamp. 189€ instead of 210€. Visit https://ti.to/cfcamp/cfcamp-2016/discount/Lucee@cfcamp
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b867299e-5326-4b15-86ed-d918aa67d907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages