I am writing the cfquery inside the cfoutput tag. It can be written outside the cfoutput tag. My question here is do we have any performance issues if we write the cfquery inside the cfoutput ?
In my experience the fastest way for the server is that you put <cfoutput></cfoutput>
only around areas that contain variables - otherwise CF has to scan through everything inside the tags to see what it does and doesn't have to translate for variables/functions.
Content unnecessarily wrapped in <cfoutput>
also tends to produce unwanted whitespace, which might influence documentsize and downloadspeed.
I don't know if there are any reliable performance tests with the latest ColdFusion versions proving my opinion, and I want to point out, that there are certainly a lot of things more important for ColdFusion performance than having <cfoutput>
in the right place (e.g. caching queries, content caching, scoping variables etc.).
From a true performance standpoint, if you use:
<cfoutput><cfquery>SELECT * FROM foo</cfquery>#now()#</cfoutput>
vs
<cfquery>SELECT * FROM foo</cfquery><cfoutput>#now()#</cfoutput>
You will not see any performance difference.
However, you should REALLY look at separating your DAO (or queries) from your views...