I think it's to be sure that the record actually exists and it's
updated.

If you make mysql update call on a non-existent record you won't get
an error, so the saveField() would return true when it should return
false. By executing the COUNT statement saveField() can return false
if the record doesn't exist

On Jun 6, 8:28 pm, Jake Moilanen <[email protected]> wrote:
> I have a very expensive background analytic process which is hammering
> my database and I am wanting to reduce the unnecessary database calls
> where ever I can.
>
> I have a general log on my database and I noticed whenever the code
> does a saveField() that first it tries getting the count on a primary
> key (which should always be 1):
>
> SELECT COUNT(*) AS `count` FROM `page_instances` AS `PageInstance`
> WHERE `PageInstance`.`id` = 3214334
> UPDATE `page_instances` SET `visible` = '0'  WHERE
> `page_instances`.`id` = 3214334
>
> I can do the UPDATE manually in my model and it avoids this SELECT
> COUNT(*), but I was unsure if getting the count was for good reason.
>
> Using version 1.2.6.
>
> Thanks,
> Jake

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to