2017-09-21 87 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的问题没有任何迹象表明这是问题。 –

相关问题