Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#1395 closed defect (bug) (wontfix)

double buffering of returned database rows

Reported by: auroraeosrose Owned by:
Milestone: Priority: normal
Severity: minor Version: 2.1
Component: Optimization Keywords:
Focuses: Cc:


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)

db.diff (383 bytes) - added by auroraeosrose 13 years ago.

Download all attachments as: .zip

Change History (9)

#1 @auroraeosrose
13 years ago

  • Patch set to No

13 years ago

#2 @rob1n
11 years ago

  • Keywords dev-feedback 2nd-opinion added
  • Milestone set to 2.2
  • Version changed from to 2.1

#3 @rob1n
11 years ago

  • Owner changed from anonymous to rob1n
  • Status changed from new to assigned

#4 @andy
11 years ago

Looks like any side-effects will be silent due to existing @ on affected lines.

Anybody going to profile this change?

#5 @rob1n
11 years ago

  • Owner rob1n deleted
  • Status changed from assigned to new

#6 @DD32
11 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.

#7 @rob1n
11 years ago

  • 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.

#8 @rob1n
11 years ago

Forgot to add: if someone wants to do the system, by all means, open this ticket back up and post your patch. I for one would love to see it.

Note: See TracTickets for help on using tickets.