Skip to main content
Inspiring
September 21, 2009
Question

cfc vs cfinclude. cfc seems slow

  • September 21, 2009
  • 1 reply
  • 2659 views

Hi,

I'm getting started changing my old cf app to use CFCs.

I have a lot of include files that contain a single query.

so, in my pages I will have something like:

<cfinclude template="/query/selAllUsers.cfm">

I've been reading basic tutorials and a lot of them go through a process where they basically put this query inside a .cfc page and makes <cffunciton> for it.

So in testing I've done this but noticed that it seems so much slower...like 3 times slower!

Is putting these queries inside a CFC not the best thing to do? I understand the appeal of the CFC approach but it seems a bit silly that something that simple would slow my pages down so much.

Thanks.

This topic has been closed for replies.

1 reply

ilssac
Inspiring
September 21, 2009

<cfinclude...>

ColdFusion load this file and run the CFML just as if it was part of the CFML in the includeing file.

CFC Component.

Load this file.

Process the CFML and instantate it into an object then store the object in memory.

Run any requested functions against the object in memory.

On a one on one race the include will almost always win.

But if one doesn't use a CFC as an include function library.  And instead uses it as a lite object, then preforance can be gained.

But there are many other benifits to components as well.  So 98.74% of the time, there are imporvements to refactoring code that can be into components.

jeremy1Author
Inspiring
September 22, 2009

Hi thanks for the response.

It turns out I was using <cfinvoke> too many times on the page. None of the tutorials I read bothered to mention that you only need to do it once for the page and then can access it like:

myComponenet.myMethod()

I switched to that and everything is speedy as ever!

Inspiring
September 22, 2009

Hi thanks for the response.

It turns out I was using <cfinvoke> too many times on the page. None of the tutorials I read bothered to mention that you only need to do it once for the page and then can access it like:

myComponenet.myMethod()

For future reference, the best first port of call when getting up to speed with CF stuff is the official documentation.  Look up your topic of interest in there, and read the official line before looking for third-party tutorials.

Here's the relevant stuff for your situation:

http://livedocs.adobe.com/coldfusion/8/htmldocs/buildingComponents_15.html#1214389

--

Adam