#1395 closed defect (bug) (wontfix)
double buffering of returned database rows
| Reported by: | auroraeosrose | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Optimization | Version: | 2.1 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: |
Description
wp-db.php grabs and stores all rows upon calling the query method, and then frees the result
it is using the mysql_query() function to do the query
This function buffers the rows internally in php - so the rows are being queried, fetched and buffered internally into php, and then moved into the db class
The end result is that the resulting rows are being buffered twice, a complete waste of memory and time
The solution is to replace the mysql_query() function with mysql_unbuffered_query()
since the results are immediately fetched and then the result freed, there should be no problems and you eliminate the extra step php is using to buffer the contents
mysql_unbuffered_query()has been available since php 4.0.6 and wordpress requires php 4.1 or higher
Attachments (1)
Change History (9)
#6
@
19 years ago
a very quick performance comparison(20 queries, 100 iterations) seems to indicate that _unbuffered is marginally faster than without. however.
http://www.onlamp.com/pub/a/onlamp/2002/04/04/webdb.html?page=last (section 8)
makes some valid points about it, It may not be the kind of function you would want to use for _all_ WP queries.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Looks like any side-effects will be silent due to existing @ on affected lines.
Anybody going to profile this change?