DB class: optimize memory usage/performance

Bug #201751 reported by Daniel Hahler
2
Affects Status Importance Assigned to Milestone
b2evolution
Fix Released
Wishlist
Unassigned
Whissip
Fix Released
Wishlist
Unassigned

Bug Description

Currently the DB class fetches all results of a query (in DB::query()) into a PHP array/cache (DB::last_result), using mysql_fetch_object().

For use cases, where you aren't using DB::get_results() to get all rows or if you do not want to use the default OBJECT format (i.e. ARRAY_A or ARRAY_N), this adds quite some overhead (memory + cpu).

EXAMPLE:
This is an example with the current code (from CommentList, using DB::get_results()):
1. mysql_query($sql)
2. for each row: mysql_fetch_object
3. for each row: convert to ARRAY_A (get_object_vars + array_values)

Instead, it should work like this:
1. mysql_query($sql)
2. for each row: mysql_fetch_array($sql, MYSQL_NUM)

To implement the $x/$y feature of e.g. DB::get_var() (to get a specific row/column), mysql_data_seek() and mysql_field_seek() would be used.

Revision history for this message
Daniel Hahler (blueyed) wrote :
Changed in b2evolution:
importance: Undecided → Wishlist
status: New → Triaged
Daniel Hahler (blueyed)
Changed in b2evolution:
status: Triaged → In Progress
Daniel Hahler (blueyed)
Changed in b2evolution:
assignee: nobody → blueyed
Revision history for this message
Daniel Hahler (blueyed) wrote :

I've implemented this now, in an own branch and will look closer at it in the next days (or weeks).

Changed in b2evolution:
status: In Progress → Fix Committed
Revision history for this message
Daniel Hahler (blueyed) wrote :

Merged into whissip a while ago already.

Revision history for this message
Daniel Hahler (blueyed) wrote :

Not in CVS yet.

Changed in b2evolution:
assignee: blueyed → nobody
status: Fix Committed → Triaged
Revision history for this message
Daniel Hahler (blueyed) wrote :

Merged into CVS Head now, too.

Changed in b2evolution:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.