New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize FieldTypesArray with static variable #367
Conversation
Looks OK to me but if since this is about performance then you should probably use EDIT: actually, make that @mnewnham thoughts ? |
Sounds correct to me. Have a look and let me know if you want me to change anything else. Thanks!! |
Why not static $arr = false;
if ($arr)
return $arr;
$arr = array();
blah blah blah.... |
Would be nice to get at least some idea of the actual performance improvement too. Is this a 1% improvement with a certain use case or 50%? |
I think this just introduced another problem along the same lines of: #381. Anytime data is cached, even in memory, there needs to be a way to clear it when schema changes and static variables make that job much more difficult. |
Revert? |
I would leave it in place for now, but I think we should figure out a better caching solution as part of #381. |
OK. |
@Mike-Benoit it turns out I've just been hit by this... See #687 |
@dregad If you revert this you can move out
out of the loop I think. But probably just a micro optimization.. |
OK Not yet sure if I'll revert or maybe try to find an alternative to using a static variable. |
Change the static array introduced in fieldTypesArray() (see #367) to a class variable ($fieldObjectsCache), so the cache now only lasts for the Recordset's lifetime. Since the mssqlnative was already using a private $fieldObjects property for the same purpose, the declaration was removed, and usages of the old name changed to match the one defined in the parent class. Fixes #687
I was profiling my application which uses ADOdb and this optimization dropped my timing significantly, but I would like to ask if this change is valid.
The tests I made seemed to be working correctly.