#1395 closed defect (bug) (wontfix)
double buffering of returned database rows
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Optimization | Version: | 2.1 |
| Severity: | minor | Keywords: | |
| Cc: |
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)
comment:1
auroraeosrose — 8 years ago
- Patch set to No
auroraeosrose — 8 years ago
- Keywords dev-feedback 2nd-opinion added
- Milestone set to 2.2
- Version changed from 1.5.1.1 to 2.1
- Owner changed from anonymous to rob1n
- Status changed from new to assigned
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.
- Keywords dev-feedback 2nd-opinion removed
- Milestone 2.2 deleted
- Resolution set to wontfix
- Status changed from new to closed
I don't think it's worth the trouble for implementing a whole system for handling unbuffered queries.

Looks like any side-effects will be silent due to existing @ on affected lines.
Anybody going to profile this change?