views:

202

answers:

3

I am wondering if there are java methods/objects that would be alternatives to cfquery, that both allow variable sanitation, and better caching methods.

I know that you can use information schema to get data types and char lengths, and then use that to validate data type & length of variables in a query.

But with everyone converting to using cfqueryparam for bind variables and variable sanitation, that also prevents using caching on a cfquery.

So I was hoping there was better ways or scripts to get more performance and scalability...

Personally, I think we need a new way or method of caching in cfquery. Because what we really want isn't to cache for x number of minutes, but to cache until the data changes, use fresh data, then cache back again, until the data changes again..

Instead for years, we've had to calculate how long we want to cache a cfquery in coldfusion, which doesn't give a lot of control or awareness of when the data was changed or not..

Does this make sense?

+4  A: 

First, let's eliminate a misconception. On CF8+, you can cache queries that use cfqueryparam. I'm not really sure what you mean by "everyone converting," either, since using it has been widely considered a best practice for a while.

So, I think your question is actually moot. While you can cache queries manually (and I do this for other datatypes) cfqueryparam hasn't been a reason to do this in a while.

Ben Doom
1. I am using cf8, most of the queries use cfqueryparam which allows variable data typing, and use of bind variables method of caching.2. I was wondering if there are other java ways of getting better performance....
crosenblum
Are you changing out the variables in cfqueryparam? If so, doesn't that defeat caching by any method?
Dan Sorensen
@crosenblum, I'm not sure I understand. Your comment says you use cfqueryparam with caching, but your question says they are mutually exclusive. Are you using caching? Also, caching does not improve DB performace, it reduces DB use. There is a difference.Also, if you need more performance, your DB is probably the first place to look, not the CF layer. While there may be ways to improve performance via Java, I believe they are likely to be minimal, and annoying to use.
Ben Doom
You are correct, we can not do caching and use cfqueryparam, which is why i was hoping there was some java method that would more native to the base that coldfusion is upon, that could help deliver better performance.I still don't see why orm delivers better performance, seems to me, and i havent' used any yet, that they add unncessary complexity to interacting with databases. Please clarify or offer some links please.
crosenblum
I've not suggested ORM. That was someone else. If you have queries that are cachable, cache them -- in CF8, you can cache queries using cfqueryparam. Also, moving to stored procedures (especially for complicated DB operations) may offer more performance.
Ben Doom
+1  A: 

If you are looking for an "alternative" method of accessing data, ORM (Object Relation Mapping) is the way to go. If you are using CF9, the Hibernate library (Java) is used under the hood to manage the access and caching of data.

CF7+ users can use the Transfer library which was built by Mark Mandel for ORM capabilities.

jarofclay
How does orm deliver better performance than normal cfqueries?
crosenblum
There are different ways to utilize ORM which can greatly affect performance. ORM can utilize a lazyload approach which will not load (request) data from the database until it is requested. At this point it will cache subsequent requests in memory. When you update the data using ORM it will update the cache. Again this is all in memory. You can see how this would greatly increase performance in busy systems.
jarofclay
A: 

In addition to jarofclay's answer I'd like to note that Transfer ORM has built-in caching system (though coming version will allow to use some even better existing solutions), this is how it delivers better performance.

Any way, I'd better started with schema and queries optimization plus tried to use caching, it can be done on really different levels: from db queries up to the rendered content.

For example, new version of Railo supports some enterprise-level caching engines like ehCache.

IMO this is better way to solve your performance task than trying to mess with Java and queries. If I understand things correctly, they still will be running through the same datasources, maybe even with same underlying byte-code.

Sergii