2017-09-21 59 views
0

我的工具如下所示使用PHP7可以提高oci8性能嗎?

  • Ubuntu的服務器16
  • PHP7
  • OCI8
  • Oracle數據庫

我與OCI8 PHP7成功安裝基本運行並從oracle的網站上開發.rpm文件。

我能夠成功連接到我的oracle數據庫並通過我的網頁返回數據。

我遇到的問題是執行查詢的時間大約是在我的PRD服務器上使用ODBC連接和OS X(Mac)上的實際Oracle驅動程序的兩倍。我不知道爲什麼表演會慢兩倍。特別是考慮到這臺服務器的硬件功能要強大得多。

任何幫助,非常感謝。

感謝

編輯:單獨實際測量的執行時間後,它看起來像他們真正是在新服務器上更快。由於codeigniter的oci8驅動程序,頁面加載似乎比較慢,我不得不猜測。

回答

1

DRCP連接池從5.3(PECL OCI8 1.3)

PHP支持Oracle數據庫駐留連接池(DRCP)。 DRCP允許更高效地使用數據庫機器內存並提供高可擴展性。使用DRCP不需要或者很少的應用程序更改。

DRCP適用於使用少量數據庫模式連接並使數據庫連接在短時間內保持打開狀態的應用程序。其他應用程序應使用Oracle的默認專用數據庫服務器進程,或使用共享服務器。

DRCP有利於所有三種連接功能,但在使用oci_pconnect()創建連接時提供最高的可擴展性。

對於OCI8中可用的DRCP,PHP使用的Oracle客戶端庫和Oracle數據庫版本必須均爲11g或更高。

有關DRCP的文檔可以在幾個Oracle手冊中找到。例如,請參閱»在Oracle文檔中配置數據庫駐留連接池以獲取使用信息。 »DRCP白皮書包含關於DRCP的背景信息。

要使用DRCP,與OCI8 1.3(或更高版本)的擴展和Oracle 11g(或更高版本)庫編譯PHP,然後按照下列步驟操作:

As a privileged database administrator, use a program like SQL*Plus to start the connection pool in the database: 

    SQL> execute dbms_connection_pool.start_pool; 

Optionally use dbms_connection_pool.alter_param() to configure DRCP settings. The current pool settings can be queried from the DBA_CPOOL_INFO view. 

Update the connection strings used. For PHP applications that currently connect using a Network Connect Name like MYDB: 

    $c = oci_pconnect("myuser", "mypassword", "MYDB"); 

modify the tnsnames.ora file and add a (SERVER=POOLED) clause, for example: 

    MYDB = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=myhost.dom.com) 
      (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales) 
      (SERVER=POOLED))) 

Alternatively, modify the Easy Connect syntax in PHP and add :POOLED after the service name: 

    $c = oci_pconnect("myuser", "mypassword", "myhost.dom.com:1521/sales:POOLED"); 

Edit php.ini and choose a connection class name. This name indicates a logical division of the connection pool and can be used to isolate pooling for separate applications. Any PHP applications with the same user name and connection class value will be able to share connections in the pool, giving greater scalability. 

    oci8.connection_class = "MY_APPLICATION_NAME" 

Run the application, connecting to the 11g (or later) database. 
+1

這看起來像一個很好的起點。謝謝 – magowan90

+0

@ magowan90我的榮幸! http://php.net/manual/en/oci8.connection.php –

+0

當DB主機沒有足夠的內存來處理工作負載時,DRCP用於可擴展性。 @ magowan90的問題沒有任何跡象表明這是問題。 –

相關問題