Improving ADODB speed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
Medium
|
Robert Lyon |
Bug Description
To make ADODB function faster I found the following information:
-------
High Speed ADOdb
ADOdb is a big class library, yet it consistently beats all other PHP class libraries in performance. This is because it is designed in a layered fashion, like an onion, with the fastest functions in the innermost layer. Stick to the following functions for best performance:
Innermost Layer
Connect, PConnect, NConnect
Execute, CacheExecute
SelectLimit, CacheSelectLimit
MoveNext, Close
qstr, Affected_Rows, Insert_ID
The fastest way to access the fields is by accessing the array $recordset->fields directly. Also set the global variables $ADODB_FETCH_MODE = ADODB_FETCH_NUM, and $ADODB_COUNTRECS = false before you connect to your database.
Consider using bind parameters if your database supports it, as it improves query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks quickly.
Installing the ADOdb C extension will speed up GetAll() and GetArray() by 100%, and GetAssoc() by 30%. It will also speed up oci8 select statements by 30%.
Lastly make sure you have a PHP accelerator cache installed such as APC, Turck MMCache, Zend Accelerator or ionCube.
Advanced Tips
If you have the ADOdb C extension installed, you can replace your calls to $rs->MoveNext() with adodb_movenext(
Execute() is the default way to run queries. You can use the low-level functions _Execute() and _query() to reduce query overhead. Both these functions share the same parameters as Execute().
If you do not have any bind parameters or your database supports binding (without emulation), then you can call _Execute() directly. Calling this function bypasses bind emulation. Debugging is still supported in _Execute().
If you do not require debugging facilities nor emulated binding, and do not require a recordset to be returned, then you can call _query. This is great for inserts, updates and deletes. Calling this function bypasses emulated binding, debugging, and recordset handling. Either the resultid, true or false are returned by _query().
Changed in mahara: | |
assignee: | nobody → Robert Lyon (robertl-9) |
status: | New → In Progress |
Changed in mahara: | |
status: | In Progress → Fix Committed |
importance: | Undecided → Medium |
milestone: | none → 15.04.0 |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
The simplest way to speed up ADODB on a linux machine is to install the php5 adodb c library. Adodb automatically detects if it is present and uses it.
sudo apt-get install php5-adodb