DB class: optimize memory usage/performance
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_
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_
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.
Related branches
- Daniel Hahler: Pending requested
Changed in b2evolution: | |
status: | Triaged → In Progress |
Changed in b2evolution: | |
assignee: | nobody → blueyed |
I've implemented this now, in an own branch and will look closer at it in the next days (or weeks).