Just noticed something counter intuituve about cake.

I was optimising a method which has a call along the lines of:

$stocked_item_details = $this->StockedItem->find(
"StockedItem.id = '$stock_item_id'");
This returns all the details of the associtated models.

Array
(
[StockedItem] => Array
(
[id] => 1
[item_id] => 10009
[supplier_id] => 1
[quantity] => 10
[unit_price] => 46.50
[buy_price] => 46.00
[created] => 9999-12-31 23:59:59
[modified] => 9999-12-31 23:59:59
)

[Product] => Array
(
[id] => 10009
[description] => Cool Stuff
[category_id] => 1
[brand_id] => 1
[reorder_level] => 4
[tax_percent] => 21.5
[image] => no-image.gif
)

[Sale] => Array
(
)

[Quote] => Array
(
)


)
The debug output read: 37 queries took 251 ms

After some refactoring I realised I only needed one field from this model and none from the associated models (for the current method).

Therefore, I included the fields parameter as in:






$stocked_item_details = $this->StockedItem->find(
"StockedItem.id = '$stock_item_id'", 
'unit_price');
Giving:
Array
(
[StockedItem] => Array
(
[unit_price] => 46.50
)

[Sale] => Array
(
)

[Quote] => Array
(
)

)

The out put from debug says that this actually takes longer!!!
37 queries took 347 ms

Can anyone tell me who this happens?
If you can, can you give some pointers for optimising?

Cheers,

Sonic.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to