Skip to main content
March 6, 2008
Answered

CFQUERY and Memory

  • March 6, 2008
  • 3 replies
  • 1623 views
Im trying to free up some memory and have a few questions..

Ive read that you can set <CFQUERY name="session.queryname"> in order to cache the record set. Im confused about how this works. Does this caching replace the use of memory that a query would use if it were named without the "session."? Or does it put the record set into memory in a manipulatable form?

Hopefully this makes sense. We're getting a 500 error message when trying to execute the template. We've narrowed it down to my page plus several others that run at the same time that are also receiving the error. So anyway we're looking for a way to free up memory during the running of our templates. If anyone has any thoughts on this it will be appreciated.

Thanks ahead of time!



This topic has been closed for replies.
Correct answer Dan_Bracuk
quote:

Originally posted by: BigFeetBigShoes
Lets pretend that it's alot.. So regardless of the amount of data and the memory thats being used, is there away to lessen the amount of memory that is used?

The best way is to reduce the amount of data returned to Cold Fusion. Ways to achieve this are:
select only the fields you need.
select only the records you need
trim character fields.

Given the way you said you are collecting your data, some of these methods may not be available to you.

3 replies

tclaremont
Inspiring
March 6, 2008
Are you returning ALL fields in the tables (tblname.*), or are you specifying explicitly which fields you want to return?
March 6, 2008
Yes, Im returning all fields from the VHI to Query call. It returns a recordset just like a query.

On an Insert statement, I wouldn't think there would be as much memory being used compared to a select statement. But correct me if Im wrong..

Inspiring
March 6, 2008
If you write your query results to a file, the file size will give you a rough idea of how much memory you are using.

March 6, 2008
Lets pretend that it's alot.. So regardless of the amount of data and the memory thats being used, is there away to lessen the amount of memory that is used?
Dan_BracukCorrect answer
Inspiring
March 6, 2008
quote:

Originally posted by: BigFeetBigShoes
Lets pretend that it's alot.. So regardless of the amount of data and the memory thats being used, is there away to lessen the amount of memory that is used?

The best way is to reduce the amount of data returned to Cold Fusion. Ways to achieve this are:
select only the fields you need.
select only the records you need
trim character fields.

Given the way you said you are collecting your data, some of these methods may not be available to you.
Inspiring
March 6, 2008
making a query a session variable makes it available to other pages so you don't have to keep running it. All queries can be manipulated to a certain with query functions

If you are having memory issues that you think might be query related, how much data is it bringing back?
March 6, 2008
Probably between 1000 and 10000 rows..one thing I did not mention is they are coming from a VHI to Query call and not an actual cfquery. (VHI is called through a customer tag that scrapes the user interface of a mainframe and returns a recordset to coldfusion) We take what we get back in the VHI recordset and load each record into a table. Is there away to dump whats kept in the temporay memory after each insert statement is ran?

If there is something that can be done with CFQUERY then I figured I would try it on the VHI custom tag along with my insert statements.