mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
MFH:
Memory usage optimisation. mysqlnd is not libmysql. mysqlnd does use the Zend allocator, which means that is easier to hit memory_limit if you have big stored (buffered) result sets. Before with libmysql you won't hit memory_limit because libmysql uses libc's allocator and nothing is checked. Now, with mysqlnd the situation is stricter and it is easier to hit memory_limit. We try to optimize for big result sets. If a result set is larger than 10 rows we will start freeing some data to keep memory usage after 10 rows constant. This will help in the cases where a buffered result set is scrolled forward only and just only once, or mysqlnd will need to decode data from the network buffers again - yes, it is a trade-off between CPU time and memory size. The best for big result sets is of course using unbuffered queries - for comparison : 3 Million rows with buffered take at least 180MB, with buffered you will stay at 3MB, and unbuffered will be just 7-8% slower.
This commit is contained in:
parent
34842709d6
commit
10ee06ca48
2 changed files with 74 additions and 8 deletions
|
@ -830,6 +830,9 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
|
|||
void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
|
||||
{
|
||||
DBG_ENTER(mysqlnd_efree_name);
|
||||
if (!ptr) {
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
#ifdef MYSQLND_THREADED
|
||||
if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
|
||||
DBG_RETURN(_mysqlnd_pefree(ptr, 1 TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue