Hi Jeremy,
Yes, you can very easily cache queries using the cachedwithin=""
attribute of <cfquery>
Like so:
<cfquery datasource="mydata" name="myquery"
cachedwithin="#createTimeSpan( 1, 0, 0, 0 )#">
SELECT COUNT( * ) FROM myTable WHERE myDate > '1900-01-01'
</cfquery>
This will cache your query for one day. You could also put the result of
the query into an application variable or something like that, but this
way the query will only be cached if the query text is the same.
M.
Jeremy Bunton wrote:
> I have a query counting records in a 25 million plus database. Even with
> indexing and what not it takes about 25 seconds to run this query. (count *
> from table where date > 19000101) Is there a way I could cache the query so
> that if it is ran in that same way it very quickly returns the full count.
> I.E. this is a dynamically build query so sometimes it will have a long
> where clause that I may be different than the straight just count everything
> thing like above. It seems to me that if that query has been ran one time
> in the same way that query should not have to recount the next time, and
> should just output the count.
>
> Jeremy
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:235619
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54