Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to improve performance of Adodb library in PHP?

Posted on 2008-09-29
4
Medium Priority
?
1,034 Views
Last Modified: 2013-12-12
We were using Adodb in the backend of our enterprise application.

When we started testing we noticed that with 2000 requests made simultaneously,
CPU usage on server is 99.6% which is very high and also error rate is high.

But when we do the same testing using the builtin mysql commands in PHP,
CPU usage on server is less than 26%.

The ADODB abstraction library is drastically decreasing the performance. Can anyone suggest tweaks to improve the performance of ADODB because we cannot remove ADODB from our application.
We tried some tweaks suggested in internet but it did not work.
Reply as soon as possible.
0
Comment
Question by:manajitrath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 29

Expert Comment

by:fibo
ID: 22596761
Do you close the adodb connection after use?

Can you paste some of your code so that we might find hints?
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 1000 total points
ID: 22598725
As ADODB consists of multiple php files which are read and parsed every time it is very time consuming. Try using a PHP-Code cache like
http://pecl.php.net/APC
http://eaccelerator.net/
Zend Platform http://www.zend.com/

Also using the ADODB will be more CPU-intensive than native mysql as most of the part is written in PHP and not in C like the native function.
0
 

Assisted Solution

by:lepricon
lepricon earned 1000 total points
ID: 23024184
As obtained from the PHP ADODB Documentation
-------------
High Speed ADOdb - tuning tips

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 field data is by accessing the array $recordset->fields directly. Also set the global variables $ADODB_FETCH_MODE = ADODB_FETCH_NUM, and (for oci8, ibase/firebird and odbc) $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. At the time of writing (Dec 2003), this means oci8 and odbc drivers.

Lastly make sure you have a PHP accelerator cache installed such as APC, Turck MMCache, Zend Accelerator or ionCube.

Some examples:
Fastest data retrieval using PHP      Fastest data retrieval using ADOdb extension

$rs =& $rs->Execute($sql);
while (!$rs->EOF) {
      var_dump($rs->fields);
      $rs->MoveNext();
}

      

$rs =& $rs->Execute($sql);
$array = adodb_getall($rs);
var_dump($array);


Advanced Tips

If you have the ADOdb C extension installed, you can replace your calls to $rs->MoveNext() with adodb_movenext($rs). This doubles the speed of this operation. For retrieving entire recordsets at once, use GetArray(), which uses the high speed extension function adodb_getall($rs) internally.

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().

For Informix, you can disable scrollable cursors with $db->cursorType = 0.
---------------
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question