Tuesday, March 30, 2010

Database connects without any queries

Hi,

Recently I've noticed that CakePHP seems to cause a database connect
for each page load (when the controller uses a model) even if the page
does not perform any database query.

On the surface of things this might make sense. My concern is that
I'm seeing database connects even when the data obtained through my
controller is clearly coming from cache. I was not too concerned
about this until I happened to be doing some database performance work
and discovered that my database is spending most of its time dealing
with connect requests.

I've taken a quick look into the CakePHP source and there seems to be
an autoConnect parameter in the __construct() method of the DboSource
class that at least sounds like the kind of thing I want to tweak, but
I've been unable to work out how get at this properly.

Does anyone know how to stop Cake connecting to the database when it
does not need to in this case?

My setup in brief:-
* CakePHP 1.3 RC3.
* mysqli
* persistent database connections
* using the mk-query-digest tool to analyze database query performance
at the wire (very useful) - http://www.maatkit.org/doc/mk-query-digest.html

Cheers,
N

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: