← Back to team overview

evoteam team mailing list archive

[Bug 201751] Re: DB class: optimize memory usage/performance

 

Merged into CVS Head now, too.

** Changed in: b2evolution
       Status: Triaged => Fix Released

-- 
DB class: optimize memory usage/performance
https://bugs.launchpad.net/bugs/201751
You received this bug notification because you are a member of Evoteam,
which is subscribed to b2evolution.

Status in b2evolution: Fix Released
Status in b2evolution whissip series: Fix Released

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.