SlideShare a Scribd company logo
1 of 79
Download to read offline
© 2009 Oracle Corporation
<Insert Picture Here>




Best Practices -
PHP and the Oracle Database
Christopher Jones, Product Development, Oracle
The following is intended to outline our general
            product direction. It is intended for information
            purposes only, and may not be incorporated into any
            contract. It is not a commitment to deliver any
            material, code, or functionality, and should not be
            relied upon in making purchasing decisions.
            The development, release, and timing of any
            features or functionality described for Oracle’s
            products remains at the sole discretion of Oracle.




© 2009 Oracle Corporation
Menu

       • Appetizer
       • Connection Techniques
       • Statement Techniques
       • Caching Techniques
       • Oracle 11gR2 and PHP OCI8 1.4




© 2009 Oracle Corporation
What is PHP OCI8?
        ●
            Recommended Oracle Database extension
        ●
            Uses prepare/execute/fetch procedural model
       $c = oci_connect('un', 'pw', 'localhost/orcl');
       $s = oci_parse($c, 'select * from employees');
       oci_execute($s);
       while (($row = oci_fetch_array($s, OCI_ASSOC)) != false)
         foreach ($row as $item)
           print $item;




© 2009 Oracle Corporation
Using OCI8 with the Oracle Database




© 2009 Oracle Corporation
Oracle Database 11.1 and PHP

       • Oracle 11.1 was released August 2007
       • Connection Pooling - DRCP
       • Database Server Query Result Cache
       • Client (aka PHP) Query Result Cache
       • Continuous Query Notification
       • Cube Organized Materialized Views
       • ...




© 2009 Oracle Corporation
PHP OCI8 1.3

       • php.net
          • PHP 5.3 Source code, Windows binaries
       • PECL - PHP Extension Community Library
          • For updating PHP 4 - 5.2 with OCI8 1.3
       • http://oss.oracle.com/projects/php
          • RPMs for Linux with OCI8
       • Unbreakable Linux Network
          • Oracle's Linux Support program
          • OCI8 RPM available for PHP
       • Zend Server
          • Linux, Windows, Mac
          • Support from Zend



© 2009 Oracle Corporation
Menu

       • Appetizer
       • ►Connection Techniques
       • Statement Techniques
       • Caching Techniques
       • Oracle 11gR2 and PHP OCI8 1.4




© 2009 Oracle Corporation
Standard OCI8 connections

       $c = oci_connect($un, $pw, $db);


       • High CPU Overhead
          • Connection establishment slow: Oracle DB is process based
          • Cannot handle the Digg effect
          • One database server process per PHP user
          • Maxes out database server memory




© 2009 Oracle Corporation
Persistent OCI8 Connections

       $c = oci_pconnect($un, $pw, $db);

       • Fast for subsequent connections
       • Not closable (prior to OCI8 1.3)
       • Some control configurable in php.ini
               oci8.max_persistent
                 Number of connections per PHP process
               oci8.persistent_timeout
                 “Idle” expiry time
               oci8.ping_interval
                 Ping after retrieving from PHP cache




© 2009 Oracle Corporation
Sidebar: Connection Quick Tips


       • Connection is faster when a character set is given

         $c = oci_pconnect("hr", "welcome", "MYDB", 'AL32UTF8');


       • For oci_connect() and oci_new_connect(), minimize
            PATH length and environment variable size of
            oracle user on database machine
             • => reduces process creation time




© 2009 Oracle Corporation
Database Resident
            Connection Pooling in 11g




© 2009 Oracle Corporation
Database Resident Connection Pooling




© 2009 Oracle Corporation
Database Resident Connection Pooling




© 2009 Oracle Corporation
Saving Memory with DRCP
           5000 users; DRCP pool size of 100

           Dedicated Mode                                          DRCP Mode

                            5000 x 4 MB +      DB Processes   100 x 4 MB +


                            5000 x 400 KB +   Session Memory 100 x 400 KB +


                            0=                 DRCP Broker    5000 x 35 KB =


                                 21 GB             Total        610 MB




© 2009 Oracle Corporation
DRCP in PHP


       • DRCP support is available in OCI8 1.3
          • when linked with Oracle 11g client libraries and
            connected to Oracle 11g
       • Works with oci_connect(), oci_new_connect(),
         oci_pconnect()
       • Use for short lived connections by same DB user




© 2009 Oracle Corporation
Configuring and Starting the Pool
       • Install PHP OCI8 1.3 and Oracle 11g
       • Configure the pool (optional)
               SQL> execute dbms_connection_pool.configure_pool(
               pool_name              => 'SYS_DEFAULT_CONNECTION_POOL',
               minsize                => 4,
               maxsize                => 40,
               incrsize               => 2,
               session_cached_cursors => 20,
               inactivity_timeout     => 300,
               max_think_time         => 600,
               max_use_session        => 500000,
               max_lifetime_session   => 86400);
       • Sart the pool:
             SQL> execute dbms_connection_pool.start_pool();  
       • Set oci8.connection_class in php.ini
             oci8.connection_class = MY_PHP_APP




© 2009 Oracle Corporation
Using DRCP

       • Add “POOLED” to the connect string:
              $c = oci_pconnect($un, $pw, 'myhost/sales:POOLED');
              Or in tnsnames.ora file connect descriptor:
         SALES = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)
                 (HOST=myhost.dom.com)
                 (PORT=1521)) 
                 (CONNECT_DATA=(SERVICE_NAME=sales)
                 (SERVER=POOLED)))
       • Application decision to use DRCP or not




© 2009 Oracle Corporation
DRCP Recommendations.

       • Read the PHP DRCP whitepaper
               http://www.oracle.com/technology/tech/php/index.html
       • Make sure oci8.connection_class is set
       • Have > 1 Broker, but only a few
       • Close connections when doing non-DB processing
       • Explicitly control commits and rollbacks
               • Avoid unexpectedly open transactions when an oci_close() or
                 end-of-scope occurs
               • Scripts coded like this can use oci_close() to take full advantage
                 of DRCP but still be portable to older versions of the OCI8 extension
       • Monitor V$CPOOL_STATS view to determine best pool size
       • Don't use for long batch processes




© 2009 Oracle Corporation
Sidebar: Transaction Tips


       • Use transactions to avoid unnecessary commits
        oci_execute($c, OCI_DEFAULT);
        . . . 
        oci_commit($c);

       • Any oci_execute($c), even for a query, will commit an
            open transaction




© 2009 Oracle Corporation
Menu

       • Appetizer
       • Connection Techniques
       • ►Statement Techniques
       • Caching Techniques
       • Oracle 11gR2 and PHP OCI8 1.4




© 2009 Oracle Corporation
Binding with SQL Statements




© 2009 Oracle Corporation
Not Binding Gives Poor Cache Use




                            Poor use of cache



© 2009 Oracle Corporation
Binding Scalars




           $c = oci_connect('hr', 'hrpwd', 'localhost/orcl');
           $s = oci_parse($c,'insert into tab values (:bv)');
           $name = 'Jones';
           oci_bind_by_name($s, ':bv', $name);
           oci_execute($s);




© 2009 Oracle Corporation
Binding Benefits
       From a query example by Tom Kyte:
                                           Without       With
       Parse count (hard)                5,000             1
       Parse time elapsed                  485            35
       Latches                         328,496       118,614

       • Can change bind values and re-execute without re-
            parsing
       •    No SQL Injection worry
       •    Easier to write than adding quote escaping
       •    Overall system is more efficient
       •    PHP user elapsed time directly benefits


© 2009 Oracle Corporation
Binding Best Practices
       • Set length parameter to your upper data size for re-
         executed IN binds oci_bind_by_name($s, “:b”, $b, 40);
       • Don't bind constants
              • Let the optimizer see them
       • Long running unique queries may not benefit
          • Parse time is a relatively small cost
       • CURSOR_SHARING parameter
          • Set in “session” or database init.ora
          • Makes every statement appear to have bound data, but
            optimizer now doesn't see constants
          • For bind-unfriendly applications
       • Oracle 11g has Adaptive Cursor Sharing
          • Can have multiple execution plans for same statement


© 2009 Oracle Corporation
Statement Caching




© 2009 Oracle Corporation
Client (aka PHP) Statement Caching
           Oracle Client library cache of statement text & meta data




                            Less traffic and DB CPU


© 2009 Oracle Corporation
Statement Caching Best Practices
       • Enabled by default in php.ini
                     oci8.statement_cache_size = 20
                      Unit is number of statements
       • Set it big enough for working set of statements




© 2009 Oracle Corporation
Row Prefetching




© 2009 Oracle Corporation
Prefetching Reduces Roundtrips
       Temporary buffer cache for query duration
       $r = oci_fetch_array(...);
       var_dump($r);
       // array('1000', 'Roma')




       $r = oci_fetch_array(...);
       var_dump($r);
       // array('1100', 'Venice')


                                                        No DB access
                                                        for next fetch

                                  Reduces round trips
© 2009 Oracle Corporation
Prefetching Reduces Query Times




                            Your results may vary

© 2009 Oracle Corporation
Prefetching is Enabled by Default

       • Enabled by default oci8.default_prefetch = 100 rows
          • Was 10 rows in OCI8 1.2
       • Tuning goal: Reduce round trips
          • but transfer reasonable chunks, not huge sets
       • Can tune per statement:

          $s = oci_parse($c, 'select city from locations');
          oci_set_prefetch($s, 87);
          oci_execute($s);
          while (($row = oci_fetch_array($s, OCI_ASSOC)) != false)
            foreach ($row as $item)
              print $item;



© 2009 Oracle Corporation
Menu

       • Appetizer
       • Connection Techniques
       • Statement Techniques
       • ►Caching Techniques
       • Oracle 11gR2 and PHP OCI8 1.4




© 2009 Oracle Corporation
Resultset Caching




© 2009 Oracle Corporation
Oracle 11g Client & Server Result Caches

       • Results of queries can be cached
          • Server and client (aka PHP) have caches
          • Recommended for small lookup tables
          • Client cache is per-process

       • Caches automatically invalidated by server data
            changes

       • Feature can be configured globally or per client
          • DB parameter:             CLIENT_RESULT_CACHE_SIZE
            Per-client in sqlnet.ora: OCI_RESULT_CACHE_MAX_SIZE
          • Has a configurable 'lag' time
             • If no roundtrip within defined time, cache assumed stale



© 2009 Oracle Corporation
No DB Access When Client Cache Used
       • With Oracle 11gR1 use Query Annotation hint

         select /*+ result_cache */ * from cjcrc


       • V$RESULT_CACHE_* views show cache usage

       • Test shows reduced DB access when client caching enabled:


             SQL> select parse_calls, executions, sql_text 
                  from v$sql where sql_text like '%cjcrc%';

             PARSE_CALLS EXECUTIONS SQL_TEXT
             ­­­­­­­­­­­ ­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
                       2        100 select * from cjcrc
                       2          2 select /*+ result_cache */ * from cjcrc




© 2009 Oracle Corporation
Result Caching Timing Test
         $c = oci_pconnect('hr', 'hrpwd', 'localhost/orcl');
         $tbls = array('locations', 'departments', 'countries');
         foreach ($tbls as $t) {
             $s = oci_parse($c, "select /*+ result_cache */ * from $t");
             oci_execute($s, OCI_DEFAULT);
             while ($row = oci_fetch_array($s, OCI_ASSOC)) {
                 foreach ($row as $item) {echo $item."n";}}}

         $ siege -c 20 -t 30S http://localhost/clientcache.php

         Without result cache: select * from $t
         Transaction rate: 32.02 trans/sec

         With result cache cache: select /*+ result_cache */ * from $t
         Transaction rate: 36.79 trans/sec

         Result Caching was approx. 15% better

© 2009 Oracle Corporation
Mid-tier Cache Invalidation by
            Continuous Query Notification




© 2009 Oracle Corporation
Continuous Query Notification Example
            Problem: update cache only when the resultset for a query changes




© 2009 Oracle Corporation
Example: Cache Depends On A Table

                $ sqlplus cj/cj

                create table cjtesttab (
                  group_id number,
                  name     varchar2(20)
                );
                insert into cjtesttab values (1, 'alison');
                insert into cjtesttab values (2, 'pearly');
                insert into cjtesttab values (2, 'wenji');




© 2009 Oracle Corporation
The PHP Cache-Updating Code

           // cqn.php
           . . .
           $tab = my_filter($_GET[tabname);
           $s = oci_parse($c, "select * from ".$tab);
           oci_execute($s);
           oci_fetch_all($s, $data);
           $memcache­>set('key', serialize($data));




© 2009 Oracle Corporation
Create 'mycallback' PL/SQL Procedure
         create or replace procedure mycallback (
                   ntfnds in cq_notification$_descriptor) is
           req  utl_http.req;
           resp utl_http.resp;
         begin
           if (ntfnds.event_type = dbms_cq_notification.event_querychange) then
             req := utl_http.begin_request(
                  'http://mycomp.us.oracle.com/~cjones/cqn.php&tabname=' 
                  || ntfnds.query_desc_array(1).table_desc_array(1).table_name);
             resp := utl_http.get_response(req);
             utl_http.end_response(resp);
           end if;
         end;
         /




© 2009 Oracle Corporation
Register 'mycallback' for a Query
         declare
           reginfo   cq_notification$_reg_info;
           v_cursor  sys_refcursor;
           regid     number;
         begin
           reginfo := cq_notification$_reg_info (
             'mycallback',                    ­­ PL/SQL callback function
             dbms_cq_notification.qos_query,   ­­ result­set notification flag
             0, 0, 0);
           regid := dbms_cq_notification.new_reg_start(reginfo);
             open v_cursor for select name from cjtesttab where group_id = 2;
             close v_cursor;
           dbms_cq_notification.reg_end;
         end;
         /



© 2009 Oracle Corporation
Example Recap
       • Table cjtesttab 
       • PHP script http://.../cqn.php to update the cache
       • PL/SQL callback procedure mycallback()
       • Registered query
         select name from cjtesttab where group_id = 2;
          • Aim: refresh mid-tier cache when the query results change




© 2009 Oracle Corporation
Example – Continuous Query In Action
       • Update the table (aiming at changing the result set):
               update cjtesttab set name = 'c' where group_id = 2;
               commit;
              • Result: Cache is refreshed


       • Update a different group_id (aiming at not changing the result
         set):
               update cjtesttab set name = 'x' where group_id = 1;
               commit;
              • No notification is generated




© 2009 Oracle Corporation
Continuous Query Notification Example




© 2009 Oracle Corporation
Menu

       • Appetizer
       • Connection Techniques
       • Statement Techniques
       • Caching Techniques
       • ►Oracle 11gR2 and PHP OCI8 1.4




© 2009 Oracle Corporation
Oracle Database 11gR2

       • Oracle 11gR2 was released September 2009
       • Many new features building on 11gR1 innovations
          • Pre-fetching supported in more places
          • Continuous Query Notification for Views
          • Client Query Result Cache (CQRC) now has table and view
            annotation
          • CQRC supported with DRCP
          • Improved views for DRCP connection pooling
       • Edition Based Redefinition
       • RAC One Node option
       • ...




© 2009 Oracle Corporation
Oracle 11gR2 Client & Server Result
           Caches
       • In Oracle 11gR1, developer adds hint to table query:

           select /*+ result_cache */ last_name  from employees


       • In Oracle 11gR2 DBA can choose tables or view to be cached:
           create table sales (...) result_cache

           alter table last_name result_cache 

           create view v2 as
              select /*+ result cache */ col1, coln from t1 

           No need to change PHP application




© 2009 Oracle Corporation
REF CURSOR Prefetching

       • New with Oracle 11.2
          • Works with 11.2 client libraries to older DBs
       • Enabled by default or set explicitly




© 2009 Oracle Corporation
REF CURSOR Prefetching
       /* create or replace
       procedure myproc(p1 out sys_refcursor) as
       begin
         open p1 for select * from tab;
       end; */

       $s = oci_parse($c, "begin myproc(:rc); end;");
       $rc = oci_new_cursor($c);
       oci_bind_by_name($s, ':rc', $rc, ­1, OCI_B_CURSOR);
       oci_execute($s);
       oci_set_prefetch($rc, 200);
       oci_execute($rc);
       oci_fetch_all($rc, $res);



© 2009 Oracle Corporation
The following is intended to outline our general
            product direction. It is intended for information
            purposes only, and may not be incorporated into any
            contract. It is not a commitment to deliver any
            material, code, or functionality, and should not be
            relied upon in making purchasing decisions.
            The development, release, and timing of any
            features or functionality described for Oracle’s
            products remains at the sole discretion of Oracle.




© 2009 Oracle Corporation
OCI8 1.4 Overview

              • PECL OCI8 1.4 Alpha released on October 6
                    • Same code was merged to PHP 5.3 & 6
                    • Will not be in PHP 5.3.1
              • OC8 1.4 builds and runs with Oracle 9.2 - 11.2
                    • OCI8 1.3 builds and runs with Oracle 9.2 - 11.2
              • Has Oracle “Attribute” support
                    • Improves tracing, logging, auditing and user security
              • Some bug fixes




© 2009 Oracle Corporation
OCI8 1.4: Tracing and Monitoring

       • Driver type is always set to “PHP OCI8”
          • needs 11.2 client libraries
          • DBA can see in V$SESSION_CONNECT_INFO
       • New functions
         oci_set_client_info($c, “My App”)   
         oci_set_module_name($c, “Home Page”)
         oci_set_action($c, “Friend Lookup”)
          • Oracle 10g+
          • User chosen strings
          • Takes effect on next “roundtrip”
          • See in various views e.g. V$SQLAREA, V$SESSION
          • Not reset for persistent connections at script end




© 2009 Oracle Corporation
OCI8 1.4: Client Identifier

       • New function:
         oci_set_client_identifer($c, “ABC”)
          • Oracle 9.2+
          • Takes effect on next “roundtrip”
          • See in various views e.g. V$SESSION
          • Not reset for persistent connections at script end

       session_start();
       $appuser = my_get_app_user($_SESSION['username']);
       $c = oci_pconnect('myuser', 'mypasswd, 'MYDB');
       oci_set_client_identifer($c, $appuser)
       ...



© 2009 Oracle Corporation
Client Identifier and Virtual Private DB
       •     Client Identifier
              •   Propagate middle tier user identity to the backend database
              •   Value can be used in access control decisions
              •   Value is recorded in audit trail
              •   Used with DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE
       • Used for Virtual Private Databases
          • Row Level Security: DBMS_RLS package
          • Uses Application Context i.e., WHERE Clause dynamically
            generated
                                                                                   y
                                   where account_mgr_id =                      olic
                                                                             DP
                                   sys_context('APP','CURRENT_MGR');       VP
             MGR_ID = 148




© 2009 Oracle Corporation
OCI8 1.4: Extras

       • New OCI_NO_AUTO_COMMIT flag
          • Alias of OCI_DEFAULT (which isn't the default option)
         oci_execute($s, OCI_NO_AUTO_COMMIT)
       • Allow row prefetch value to be 0
          • Avoids row “loss” if passing REF CURSORS back and forth
            between PHP and PL/SQL
       • New oci_set_edition() procedure




© 2009 Oracle Corporation
Upgrading Live Sites




© 2009 Oracle Corporation
Edition Based Redefinition

       • EBR allows application upgrade and testing while
         still in production use
       • Oracle 11gR introduces EBR and the:
              • Edition
              • Editioning view
              • Crossedition trigger
       • EBR allows multiple versions of DB objects to be
            used concurrently




© 2009 Oracle Corporation
EBR and PHP Applications
       • Use EBR in conjunction with PHP code changes
          • Load balancer/web server needs to call correct version of
            PHP scripts
       • Use EBR for
              • A/B testing
              • Application migration and release testing




© 2009 Oracle Corporation
Application Version 1: DB Objects

          Requirement: Show number of days vacation for employees

          SQL> create table myemp (name varchar2(10), 
                                   hoursworked number);
          SQL> insert into myemp values ('alison', 200);

          SQL> create function vacationdaysleft(p_name in varchar2)
          return number as
            vdl number;
          begin
            select floor(hoursworked / 40) into vdl
              from myemp where name = p_name;
            return vdl;
          end;




© 2009 Oracle Corporation
Application Version 1: PHP Code
       // vacation1.php

       oci_set_edition('ora$base');  // OCI8 1.4
       $c = oci_connect('cj','welcome','localhost/orcl');

       $s = oci_parse($c, 
              “begin :vdl := vacationdaysleft('alison'); end;”);
       oci_bind_by_name($s, “:vdl”, $vdl, 15);
       oci_execute($s);
       echo “alison has “ . $vdl . ” days vacation leftn”;

       $ php vacation1.php
       alison has 5 days vacation left




       •




© 2009 Oracle Corporation
EBR Recap: Application Version 1

       • One vacation1.php script
       • One vacationdaysleft stored function
       • One myemp table
       • One set of users accessing the application




© 2009 Oracle Corporation
Application Version 2: DB Schema

           New Requirement: Alter the vacation rate calculation

           SQL> create edition e2;
           SQL> alter session set edition = e2;

           SQL> create function vacationdaysleft(p_name in varchar2)
              return number as
              vdl number;
            begin
             select floor(hoursworked / 20) into vdl 
               from myemp where name = p_name;
             return vdl;
           end;




© 2009 Oracle Corporation
Application Version 2: PHP Code

          // vacation2.php

          oci_set_edition('e2');  // OCI8 1.4
          $c = oci_connect('cj','welcome','localhost/orcl');

          $s = oci_parse($c, 
                 “begin :vdl := vacationdaysleft('alison'); end;”);
          oci_bind_by_name($s, “:vdl”, $vdl, 15);
          oci_execute($s);
          echo “alison now has “ . $vdl . ” days vacation leftn”;




© 2009 Oracle Corporation
Recap: Edition Based Redefinition
       • Two scripts: vacation1.php and vacation2.php
       • Two vacationdaysleft stored functions in same schema
       • One myemp table
       • Two sets of web users running different versions concurrently


       $ php vacation1.php
       alison has 5 days vacation left
       $ php vacation2.php
       alison now has 10 days vacation left


       • When migration completed, use DROP EDITION
       • Use oci_set_edition() not ALTER SESSION in PHP




© 2009 Oracle Corporation
Oracle Database
          and PHP Roadmap




© 2009 Oracle Corporation
Oracle Database and PHP Roadmap

           • PDO_OCI
              • There is a disconnect between PDO_xxx users and
                maintainers
              • PDO_xxx drivers are not well maintained




© 2009 Oracle Corporation
Oracle Database and PHP Roadmap

           • PHP OCI8 integration with
              • TimesTen In Memory Database
                 • A fast in memory, persistent DB
              • TimesTen In Memory Database Cache
                 • Cache for Oracle Database
              • No need for separate caching logic




© 2009 Oracle Corporation
Some PHP & Oracle Books




© 2009 Oracle Corporation
The preceding is intended to outline our general
            product direction. It is intended for information
            purposes only, and may not be incorporated into any
            contract. It is not a commitment to deliver any
            material, code, or functionality, and should not be
            relied upon in making purchasing decisions.
            The development, release, and timing of any
            features or functionality described for Oracle’s
            products remains at the sole discretion of Oracle.




© 2009 Oracle Corporation
Oracle Resources

         Oracle Techology Network (OTN)
           – PHP Developer Center: otn.oracle.com/php
               – Free book: Underground PHP and Oracle Manual
               – Whitepapers, Articles, FAQs, links to blogs
               – PHP Extension, PHP RPMs
         Information
               –     christopher.jones@oracle.com
               –     blogs.oracle.com/opal
               –     kuassi.mensah@oracle.com
               –     db360.blogspot.com
         SQL and PL/SQL Questions
               – asktom.oracle.com
         ISVs and hardware vendors
               – oraclepartnernetwork.oracle.com



© 2009 Oracle Corporation
© 2009 Oracle Corporation
Extra Slides




© 2009 Oracle Corporation
DBMS_XA: Transactions Across Requests
       • Oracle 11gR1 Feature
          • Can we use it on the web? Upgrading thick client applications?
       • Example from http://tinyurl.com/dbmsxaex
          HTTP Request #1:
         rc  := DBMS_XA.XA_START(DBMS_XA_XID(123), DBMS_XA.TMNOFLAGS);
         UPDATE employees SET salary=salary*1.1 WHERE employee_id = 100;
         rc  := DBMS_XA.XA_END(DBMS_XA_XID(123), DBMS_XA.TMSUSPEND);


          HTTP Request #2:
         rc  := DBMS_XA.XA_START(DBMS_XA_XID(123), DBMS_XA.TMRESUME);
         SELECT salary INTO s FROM employees WHERE employee_id = 100;
         rc  := DBMS_XA.XA_END(DBMS_XA_XID(123), DBMS_XA.TMSUCCESS);
            
          HTTP Request #3:
         rc  := DBMS_XA.XA_COMMIT(DBMS_XA_XID(123), TRUE);



© 2009 Oracle Corporation
Hey Look! Free Stuff


       • Oracle Instant Client
          • Easy to install
          • Client libraries for C, C++, Java, .Net access to a remote DB
       • Oracle Database Express Edition (aka “XE”)
          • Same code base as full database
          • Windows & Linux 32 bit
       • SQL Developer
          • Thick client SQL and PL/SQL development tool
          • Connects to MySQL too
       • Application Express (“Apex”)
          • Web based Application Development tool
          • Try it at http://apex.oracle.com/


© 2009 Oracle Corporation
PHP DRCP Benchmark




                                ●
                                    See PHP DRCP Whitepaper
                                ●
                                    2GB RAM
                                ●
                                    1 connection broker
                                ●
                                    100 pooled servers




© 2009 Oracle Corporation

More Related Content

What's hot

Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraTomislav Plavcic
 
New Generation Oracle RAC Performance
New Generation Oracle RAC PerformanceNew Generation Oracle RAC Performance
New Generation Oracle RAC PerformanceAnil Nair
 
Oracle rac资源管理算法与cache fusion实现浅析
Oracle rac资源管理算法与cache fusion实现浅析Oracle rac资源管理算法与cache fusion实现浅析
Oracle rac资源管理算法与cache fusion实现浅析frogd
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsJohn Beresniewicz
 
Oracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System AdministrationOracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System AdministrationMozammel Hoque
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slidesMohamed Farouk
 
Oracle Sql Developer Data Modeler 3 3 new features
Oracle Sql Developer Data Modeler 3 3 new featuresOracle Sql Developer Data Modeler 3 3 new features
Oracle Sql Developer Data Modeler 3 3 new featuresPhilip Stoyanov
 
Indexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12cIndexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12cOren Nakdimon
 
mysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementmysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementlalit choudhary
 
Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013John Beresniewicz
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
MySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxMySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxNeoClova
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginnersPini Dibask
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuningSimon Huang
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfSrirakshaSrinivasan2
 
Oracle RAC features on Exadata
Oracle RAC features on ExadataOracle RAC features on Exadata
Oracle RAC features on ExadataAnil Nair
 

What's hot (20)

Oracle ASM Training
Oracle ASM TrainingOracle ASM Training
Oracle ASM Training
 
Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfra
 
New Generation Oracle RAC Performance
New Generation Oracle RAC PerformanceNew Generation Oracle RAC Performance
New Generation Oracle RAC Performance
 
Oracle rac资源管理算法与cache fusion实现浅析
Oracle rac资源管理算法与cache fusion实现浅析Oracle rac资源管理算法与cache fusion实现浅析
Oracle rac资源管理算法与cache fusion实现浅析
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
 
Oracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System AdministrationOracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System Administration
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slides
 
Oracle Sql Developer Data Modeler 3 3 new features
Oracle Sql Developer Data Modeler 3 3 new featuresOracle Sql Developer Data Modeler 3 3 new features
Oracle Sql Developer Data Modeler 3 3 new features
 
Indexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12cIndexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12c
 
mysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementmysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancement
 
ASM
ASMASM
ASM
 
Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
MySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxMySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docx
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginners
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
 
Oracle RAC features on Exadata
Oracle RAC features on ExadataOracle RAC features on Exadata
Oracle RAC features on Exadata
 

Viewers also liked

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overviewhonglee71
 
What’s New in Oracle Database 12c for PHP
What’s New in Oracle Database 12c for PHPWhat’s New in Oracle Database 12c for PHP
What’s New in Oracle Database 12c for PHPChristopher Jones
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQLlubna19
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and ArchitectureSidney Chen
 
Infografia placa base (frederik sebastian escobar otavo)
Infografia placa base (frederik sebastian escobar otavo)Infografia placa base (frederik sebastian escobar otavo)
Infografia placa base (frederik sebastian escobar otavo)fseo118
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture pptDeepak Shetty
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsqlSid Xing
 
Oracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksOracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksJeff Smith
 
All of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL DeveloperAll of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL DeveloperJeff Smith
 
Object Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHPObject Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHPRobertGonzalez
 
Open Source Package PHP & MySQL
Open Source Package PHP & MySQLOpen Source Package PHP & MySQL
Open Source Package PHP & MySQLkalaisai
 
Mastering DevOps With Oracle
Mastering DevOps With OracleMastering DevOps With Oracle
Mastering DevOps With OracleKelly Goetsch
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answersiimjobs and hirist
 
Microservices + Oracle: A Bright Future
Microservices + Oracle: A Bright FutureMicroservices + Oracle: A Bright Future
Microservices + Oracle: A Bright FutureKelly Goetsch
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web ServicesBruno Pedro
 

Viewers also liked (20)

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
What’s New in Oracle Database 12c for PHP
What’s New in Oracle Database 12c for PHPWhat’s New in Oracle Database 12c for PHP
What’s New in Oracle Database 12c for PHP
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQL
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
 
PHP Oracle
PHP OraclePHP Oracle
PHP Oracle
 
Infografia placa base (frederik sebastian escobar otavo)
Infografia placa base (frederik sebastian escobar otavo)Infografia placa base (frederik sebastian escobar otavo)
Infografia placa base (frederik sebastian escobar otavo)
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture ppt
 
Oracle Essentials Oracle Database 11g
Oracle Essentials   Oracle Database 11gOracle Essentials   Oracle Database 11g
Oracle Essentials Oracle Database 11g
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsql
 
Oracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksOracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & Tricks
 
All of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL DeveloperAll of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL Developer
 
Object Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHPObject Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHP
 
Open Source Package PHP & MySQL
Open Source Package PHP & MySQLOpen Source Package PHP & MySQL
Open Source Package PHP & MySQL
 
Mastering DevOps With Oracle
Mastering DevOps With OracleMastering DevOps With Oracle
Mastering DevOps With Oracle
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
 
Microservices + Oracle: A Bright Future
Microservices + Oracle: A Bright FutureMicroservices + Oracle: A Bright Future
Microservices + Oracle: A Bright Future
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web Services
 
Oracle ERP Introduction
Oracle ERP IntroductionOracle ERP Introduction
Oracle ERP Introduction
 

Similar to Best Practices - PHP and the Oracle Database

PHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Barcelona Conference
 
[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...
[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...
[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...Insight Technology, Inc.
 
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilitySolving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilityZendCon
 
Less06 networking
Less06 networkingLess06 networking
Less06 networkingAmit Bhalla
 
Oracle Cloud DBaaS
Oracle Cloud DBaaSOracle Cloud DBaaS
Oracle Cloud DBaaSArush Jain
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesChristopher Jones
 
VMworld 2013: Virtualizing Databases: Doing IT Right
VMworld 2013: Virtualizing Databases: Doing IT Right VMworld 2013: Virtualizing Databases: Doing IT Right
VMworld 2013: Virtualizing Databases: Doing IT Right VMworld
 
0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorialKlausePaulino
 
Oracle Enterprise Manager - EM12c R5 Hybrid Cloud Management
Oracle Enterprise Manager - EM12c R5 Hybrid Cloud ManagementOracle Enterprise Manager - EM12c R5 Hybrid Cloud Management
Oracle Enterprise Manager - EM12c R5 Hybrid Cloud ManagementMarketingArrowECS_CZ
 
Hacking Oracle Web Applications With Metasploit
Hacking Oracle Web Applications With MetasploitHacking Oracle Web Applications With Metasploit
Hacking Oracle Web Applications With MetasploitChris Gates
 
Oracle database in cloud, dr in cloud and overview of oracle database 18c
Oracle database in cloud, dr in cloud and overview of oracle database 18cOracle database in cloud, dr in cloud and overview of oracle database 18c
Oracle database in cloud, dr in cloud and overview of oracle database 18cAiougVizagChapter
 
Oracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with PuppetOracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with PuppetEdwin Biemond
 
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009eLiberatica
 
MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014Dave Stokes
 
Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...
Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...
Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...Amazon Web Services
 
Data Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol BuffersData Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol BuffersWilliam Kibira
 

Similar to Best Practices - PHP and the Oracle Database (20)

ORACLE
ORACLEORACLE
ORACLE
 
PHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi Mensah
 
[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...
[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...
[db tech showcase Tokyo 2018] #dbts2018 #B31 『1,2,3 and Done! 3 easy ways to ...
 
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilitySolving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
 
Less06 networking
Less06 networkingLess06 networking
Less06 networking
 
Oracle Cloud DBaaS
Oracle Cloud DBaaSOracle Cloud DBaaS
Oracle Cloud DBaaS
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development Techniques
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 
VMworld 2013: Virtualizing Databases: Doing IT Right
VMworld 2013: Virtualizing Databases: Doing IT Right VMworld 2013: Virtualizing Databases: Doing IT Right
VMworld 2013: Virtualizing Databases: Doing IT Right
 
Oracle Database Cloud Service
Oracle Database Cloud ServiceOracle Database Cloud Service
Oracle Database Cloud Service
 
0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial
 
Oracle Enterprise Manager - EM12c R5 Hybrid Cloud Management
Oracle Enterprise Manager - EM12c R5 Hybrid Cloud ManagementOracle Enterprise Manager - EM12c R5 Hybrid Cloud Management
Oracle Enterprise Manager - EM12c R5 Hybrid Cloud Management
 
Hacking Oracle Web Applications With Metasploit
Hacking Oracle Web Applications With MetasploitHacking Oracle Web Applications With Metasploit
Hacking Oracle Web Applications With Metasploit
 
Hacking oracle using metasploit
Hacking oracle using metasploitHacking oracle using metasploit
Hacking oracle using metasploit
 
Oracle database in cloud, dr in cloud and overview of oracle database 18c
Oracle database in cloud, dr in cloud and overview of oracle database 18cOracle database in cloud, dr in cloud and overview of oracle database 18c
Oracle database in cloud, dr in cloud and overview of oracle database 18c
 
Oracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with PuppetOracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with Puppet
 
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
 
MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014
 
Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...
Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...
Migrate from Oracle to Aurora PostgreSQL: Best Practices, Design Patterns, & ...
 
Data Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol BuffersData Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol Buffers
 

Recently uploaded

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Best Practices - PHP and the Oracle Database

  • 1. © 2009 Oracle Corporation
  • 2. <Insert Picture Here> Best Practices - PHP and the Oracle Database Christopher Jones, Product Development, Oracle
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. © 2009 Oracle Corporation
  • 4. Menu • Appetizer • Connection Techniques • Statement Techniques • Caching Techniques • Oracle 11gR2 and PHP OCI8 1.4 © 2009 Oracle Corporation
  • 5. What is PHP OCI8? ● Recommended Oracle Database extension ● Uses prepare/execute/fetch procedural model   $c = oci_connect('un', 'pw', 'localhost/orcl');   $s = oci_parse($c, 'select * from employees');   oci_execute($s);   while (($row = oci_fetch_array($s, OCI_ASSOC)) != false)     foreach ($row as $item)       print $item; © 2009 Oracle Corporation
  • 6. Using OCI8 with the Oracle Database © 2009 Oracle Corporation
  • 7. Oracle Database 11.1 and PHP • Oracle 11.1 was released August 2007 • Connection Pooling - DRCP • Database Server Query Result Cache • Client (aka PHP) Query Result Cache • Continuous Query Notification • Cube Organized Materialized Views • ... © 2009 Oracle Corporation
  • 8. PHP OCI8 1.3 • php.net • PHP 5.3 Source code, Windows binaries • PECL - PHP Extension Community Library • For updating PHP 4 - 5.2 with OCI8 1.3 • http://oss.oracle.com/projects/php • RPMs for Linux with OCI8 • Unbreakable Linux Network • Oracle's Linux Support program • OCI8 RPM available for PHP • Zend Server • Linux, Windows, Mac • Support from Zend © 2009 Oracle Corporation
  • 9. Menu • Appetizer • ►Connection Techniques • Statement Techniques • Caching Techniques • Oracle 11gR2 and PHP OCI8 1.4 © 2009 Oracle Corporation
  • 10. Standard OCI8 connections $c = oci_connect($un, $pw, $db); • High CPU Overhead • Connection establishment slow: Oracle DB is process based • Cannot handle the Digg effect • One database server process per PHP user • Maxes out database server memory © 2009 Oracle Corporation
  • 11. Persistent OCI8 Connections $c = oci_pconnect($un, $pw, $db); • Fast for subsequent connections • Not closable (prior to OCI8 1.3) • Some control configurable in php.ini oci8.max_persistent Number of connections per PHP process oci8.persistent_timeout “Idle” expiry time oci8.ping_interval Ping after retrieving from PHP cache © 2009 Oracle Corporation
  • 12. Sidebar: Connection Quick Tips • Connection is faster when a character set is given   $c = oci_pconnect("hr", "welcome", "MYDB", 'AL32UTF8'); • For oci_connect() and oci_new_connect(), minimize PATH length and environment variable size of oracle user on database machine • => reduces process creation time © 2009 Oracle Corporation
  • 13. Database Resident Connection Pooling in 11g © 2009 Oracle Corporation
  • 14. Database Resident Connection Pooling © 2009 Oracle Corporation
  • 15. Database Resident Connection Pooling © 2009 Oracle Corporation
  • 16. Saving Memory with DRCP 5000 users; DRCP pool size of 100 Dedicated Mode DRCP Mode 5000 x 4 MB + DB Processes 100 x 4 MB + 5000 x 400 KB + Session Memory 100 x 400 KB + 0= DRCP Broker 5000 x 35 KB = 21 GB Total 610 MB © 2009 Oracle Corporation
  • 17. DRCP in PHP • DRCP support is available in OCI8 1.3 • when linked with Oracle 11g client libraries and connected to Oracle 11g • Works with oci_connect(), oci_new_connect(), oci_pconnect() • Use for short lived connections by same DB user © 2009 Oracle Corporation
  • 18. Configuring and Starting the Pool • Install PHP OCI8 1.3 and Oracle 11g • Configure the pool (optional) SQL> execute dbms_connection_pool.configure_pool( pool_name              => 'SYS_DEFAULT_CONNECTION_POOL', minsize                => 4, maxsize                => 40, incrsize               => 2, session_cached_cursors => 20, inactivity_timeout     => 300, max_think_time         => 600, max_use_session        => 500000, max_lifetime_session   => 86400); • Sart the pool:       SQL> execute dbms_connection_pool.start_pool();   • Set oci8.connection_class in php.ini       oci8.connection_class = MY_PHP_APP © 2009 Oracle Corporation
  • 19. Using DRCP • Add “POOLED” to the connect string: $c = oci_pconnect($un, $pw, 'myhost/sales:POOLED'); Or in tnsnames.ora file connect descriptor:   SALES = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)           (HOST=myhost.dom.com)           (PORT=1521))            (CONNECT_DATA=(SERVICE_NAME=sales)           (SERVER=POOLED))) • Application decision to use DRCP or not © 2009 Oracle Corporation
  • 20. DRCP Recommendations. • Read the PHP DRCP whitepaper http://www.oracle.com/technology/tech/php/index.html • Make sure oci8.connection_class is set • Have > 1 Broker, but only a few • Close connections when doing non-DB processing • Explicitly control commits and rollbacks • Avoid unexpectedly open transactions when an oci_close() or end-of-scope occurs • Scripts coded like this can use oci_close() to take full advantage of DRCP but still be portable to older versions of the OCI8 extension • Monitor V$CPOOL_STATS view to determine best pool size • Don't use for long batch processes © 2009 Oracle Corporation
  • 21. Sidebar: Transaction Tips • Use transactions to avoid unnecessary commits  oci_execute($c, OCI_DEFAULT);  . . .   oci_commit($c); • Any oci_execute($c), even for a query, will commit an open transaction © 2009 Oracle Corporation
  • 22. Menu • Appetizer • Connection Techniques • ►Statement Techniques • Caching Techniques • Oracle 11gR2 and PHP OCI8 1.4 © 2009 Oracle Corporation
  • 23. Binding with SQL Statements © 2009 Oracle Corporation
  • 24. Not Binding Gives Poor Cache Use Poor use of cache © 2009 Oracle Corporation
  • 25. Binding Scalars   $c = oci_connect('hr', 'hrpwd', 'localhost/orcl');   $s = oci_parse($c,'insert into tab values (:bv)');   $name = 'Jones';   oci_bind_by_name($s, ':bv', $name);   oci_execute($s); © 2009 Oracle Corporation
  • 26. Binding Benefits From a query example by Tom Kyte: Without With Parse count (hard) 5,000 1 Parse time elapsed 485 35 Latches 328,496 118,614 • Can change bind values and re-execute without re- parsing • No SQL Injection worry • Easier to write than adding quote escaping • Overall system is more efficient • PHP user elapsed time directly benefits © 2009 Oracle Corporation
  • 27. Binding Best Practices • Set length parameter to your upper data size for re- executed IN binds oci_bind_by_name($s, “:b”, $b, 40); • Don't bind constants • Let the optimizer see them • Long running unique queries may not benefit • Parse time is a relatively small cost • CURSOR_SHARING parameter • Set in “session” or database init.ora • Makes every statement appear to have bound data, but optimizer now doesn't see constants • For bind-unfriendly applications • Oracle 11g has Adaptive Cursor Sharing • Can have multiple execution plans for same statement © 2009 Oracle Corporation
  • 28. Statement Caching © 2009 Oracle Corporation
  • 29. Client (aka PHP) Statement Caching Oracle Client library cache of statement text & meta data Less traffic and DB CPU © 2009 Oracle Corporation
  • 30. Statement Caching Best Practices • Enabled by default in php.ini oci8.statement_cache_size = 20 Unit is number of statements • Set it big enough for working set of statements © 2009 Oracle Corporation
  • 31. Row Prefetching © 2009 Oracle Corporation
  • 32. Prefetching Reduces Roundtrips Temporary buffer cache for query duration $r = oci_fetch_array(...); var_dump($r); // array('1000', 'Roma') $r = oci_fetch_array(...); var_dump($r); // array('1100', 'Venice') No DB access for next fetch Reduces round trips © 2009 Oracle Corporation
  • 33. Prefetching Reduces Query Times Your results may vary © 2009 Oracle Corporation
  • 34. Prefetching is Enabled by Default • Enabled by default oci8.default_prefetch = 100 rows • Was 10 rows in OCI8 1.2 • Tuning goal: Reduce round trips • but transfer reasonable chunks, not huge sets • Can tune per statement:   $s = oci_parse($c, 'select city from locations');   oci_set_prefetch($s, 87);   oci_execute($s);   while (($row = oci_fetch_array($s, OCI_ASSOC)) != false)     foreach ($row as $item)       print $item; © 2009 Oracle Corporation
  • 35. Menu • Appetizer • Connection Techniques • Statement Techniques • ►Caching Techniques • Oracle 11gR2 and PHP OCI8 1.4 © 2009 Oracle Corporation
  • 36. Resultset Caching © 2009 Oracle Corporation
  • 37. Oracle 11g Client & Server Result Caches • Results of queries can be cached • Server and client (aka PHP) have caches • Recommended for small lookup tables • Client cache is per-process • Caches automatically invalidated by server data changes • Feature can be configured globally or per client • DB parameter: CLIENT_RESULT_CACHE_SIZE Per-client in sqlnet.ora: OCI_RESULT_CACHE_MAX_SIZE • Has a configurable 'lag' time • If no roundtrip within defined time, cache assumed stale © 2009 Oracle Corporation
  • 38. No DB Access When Client Cache Used • With Oracle 11gR1 use Query Annotation hint   select /*+ result_cache */ * from cjcrc • V$RESULT_CACHE_* views show cache usage • Test shows reduced DB access when client caching enabled: SQL> select parse_calls, executions, sql_text       from v$sql where sql_text like '%cjcrc%'; PARSE_CALLS EXECUTIONS SQL_TEXT ­­­­­­­­­­­ ­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­           2        100 select * from cjcrc           2          2 select /*+ result_cache */ * from cjcrc © 2009 Oracle Corporation
  • 39. Result Caching Timing Test $c = oci_pconnect('hr', 'hrpwd', 'localhost/orcl'); $tbls = array('locations', 'departments', 'countries'); foreach ($tbls as $t) {     $s = oci_parse($c, "select /*+ result_cache */ * from $t");     oci_execute($s, OCI_DEFAULT);     while ($row = oci_fetch_array($s, OCI_ASSOC)) {         foreach ($row as $item) {echo $item."n";}}} $ siege -c 20 -t 30S http://localhost/clientcache.php Without result cache: select * from $t Transaction rate: 32.02 trans/sec With result cache cache: select /*+ result_cache */ * from $t Transaction rate: 36.79 trans/sec Result Caching was approx. 15% better © 2009 Oracle Corporation
  • 40. Mid-tier Cache Invalidation by Continuous Query Notification © 2009 Oracle Corporation
  • 41. Continuous Query Notification Example Problem: update cache only when the resultset for a query changes © 2009 Oracle Corporation
  • 42. Example: Cache Depends On A Table $ sqlplus cj/cj create table cjtesttab (   group_id number,   name     varchar2(20) ); insert into cjtesttab values (1, 'alison'); insert into cjtesttab values (2, 'pearly'); insert into cjtesttab values (2, 'wenji'); © 2009 Oracle Corporation
  • 43. The PHP Cache-Updating Code // cqn.php . . . $tab = my_filter($_GET[tabname); $s = oci_parse($c, "select * from ".$tab); oci_execute($s); oci_fetch_all($s, $data); $memcache­>set('key', serialize($data)); © 2009 Oracle Corporation
  • 44. Create 'mycallback' PL/SQL Procedure create or replace procedure mycallback (           ntfnds in cq_notification$_descriptor) is   req  utl_http.req;   resp utl_http.resp; begin   if (ntfnds.event_type = dbms_cq_notification.event_querychange) then     req := utl_http.begin_request(          'http://mycomp.us.oracle.com/~cjones/cqn.php&tabname='           || ntfnds.query_desc_array(1).table_desc_array(1).table_name);     resp := utl_http.get_response(req);     utl_http.end_response(resp);   end if; end; / © 2009 Oracle Corporation
  • 45. Register 'mycallback' for a Query declare   reginfo   cq_notification$_reg_info;   v_cursor  sys_refcursor;   regid     number; begin   reginfo := cq_notification$_reg_info (     'mycallback',                    ­­ PL/SQL callback function     dbms_cq_notification.qos_query,   ­­ result­set notification flag     0, 0, 0);   regid := dbms_cq_notification.new_reg_start(reginfo);     open v_cursor for select name from cjtesttab where group_id = 2;     close v_cursor;   dbms_cq_notification.reg_end; end; / © 2009 Oracle Corporation
  • 46. Example Recap • Table cjtesttab  • PHP script http://.../cqn.php to update the cache • PL/SQL callback procedure mycallback() • Registered query   select name from cjtesttab where group_id = 2; • Aim: refresh mid-tier cache when the query results change © 2009 Oracle Corporation
  • 47. Example – Continuous Query In Action • Update the table (aiming at changing the result set):  update cjtesttab set name = 'c' where group_id = 2;  commit; • Result: Cache is refreshed • Update a different group_id (aiming at not changing the result set):  update cjtesttab set name = 'x' where group_id = 1;  commit; • No notification is generated © 2009 Oracle Corporation
  • 48. Continuous Query Notification Example © 2009 Oracle Corporation
  • 49. Menu • Appetizer • Connection Techniques • Statement Techniques • Caching Techniques • ►Oracle 11gR2 and PHP OCI8 1.4 © 2009 Oracle Corporation
  • 50. Oracle Database 11gR2 • Oracle 11gR2 was released September 2009 • Many new features building on 11gR1 innovations • Pre-fetching supported in more places • Continuous Query Notification for Views • Client Query Result Cache (CQRC) now has table and view annotation • CQRC supported with DRCP • Improved views for DRCP connection pooling • Edition Based Redefinition • RAC One Node option • ... © 2009 Oracle Corporation
  • 51. Oracle 11gR2 Client & Server Result Caches • In Oracle 11gR1, developer adds hint to table query:     select /*+ result_cache */ last_name  from employees • In Oracle 11gR2 DBA can choose tables or view to be cached:     create table sales (...) result_cache     alter table last_name result_cache      create view v2 as        select /*+ result cache */ col1, coln from t1  No need to change PHP application © 2009 Oracle Corporation
  • 52. REF CURSOR Prefetching • New with Oracle 11.2 • Works with 11.2 client libraries to older DBs • Enabled by default or set explicitly © 2009 Oracle Corporation
  • 53. REF CURSOR Prefetching /* create or replace procedure myproc(p1 out sys_refcursor) as begin   open p1 for select * from tab; end; */ $s = oci_parse($c, "begin myproc(:rc); end;"); $rc = oci_new_cursor($c); oci_bind_by_name($s, ':rc', $rc, ­1, OCI_B_CURSOR); oci_execute($s); oci_set_prefetch($rc, 200); oci_execute($rc); oci_fetch_all($rc, $res); © 2009 Oracle Corporation
  • 54. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. © 2009 Oracle Corporation
  • 55. OCI8 1.4 Overview • PECL OCI8 1.4 Alpha released on October 6 • Same code was merged to PHP 5.3 & 6 • Will not be in PHP 5.3.1 • OC8 1.4 builds and runs with Oracle 9.2 - 11.2 • OCI8 1.3 builds and runs with Oracle 9.2 - 11.2 • Has Oracle “Attribute” support • Improves tracing, logging, auditing and user security • Some bug fixes © 2009 Oracle Corporation
  • 56. OCI8 1.4: Tracing and Monitoring • Driver type is always set to “PHP OCI8” • needs 11.2 client libraries • DBA can see in V$SESSION_CONNECT_INFO • New functions   oci_set_client_info($c, “My App”)      oci_set_module_name($c, “Home Page”)   oci_set_action($c, “Friend Lookup”) • Oracle 10g+ • User chosen strings • Takes effect on next “roundtrip” • See in various views e.g. V$SQLAREA, V$SESSION • Not reset for persistent connections at script end © 2009 Oracle Corporation
  • 57. OCI8 1.4: Client Identifier • New function:   oci_set_client_identifer($c, “ABC”) • Oracle 9.2+ • Takes effect on next “roundtrip” • See in various views e.g. V$SESSION • Not reset for persistent connections at script end session_start(); $appuser = my_get_app_user($_SESSION['username']); $c = oci_pconnect('myuser', 'mypasswd, 'MYDB'); oci_set_client_identifer($c, $appuser) ... © 2009 Oracle Corporation
  • 58. Client Identifier and Virtual Private DB • Client Identifier • Propagate middle tier user identity to the backend database • Value can be used in access control decisions • Value is recorded in audit trail • Used with DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE • Used for Virtual Private Databases • Row Level Security: DBMS_RLS package • Uses Application Context i.e., WHERE Clause dynamically generated y where account_mgr_id = olic DP sys_context('APP','CURRENT_MGR'); VP MGR_ID = 148 © 2009 Oracle Corporation
  • 59. OCI8 1.4: Extras • New OCI_NO_AUTO_COMMIT flag • Alias of OCI_DEFAULT (which isn't the default option)   oci_execute($s, OCI_NO_AUTO_COMMIT) • Allow row prefetch value to be 0 • Avoids row “loss” if passing REF CURSORS back and forth between PHP and PL/SQL • New oci_set_edition() procedure © 2009 Oracle Corporation
  • 60. Upgrading Live Sites © 2009 Oracle Corporation
  • 61. Edition Based Redefinition • EBR allows application upgrade and testing while still in production use • Oracle 11gR introduces EBR and the: • Edition • Editioning view • Crossedition trigger • EBR allows multiple versions of DB objects to be used concurrently © 2009 Oracle Corporation
  • 62. EBR and PHP Applications • Use EBR in conjunction with PHP code changes • Load balancer/web server needs to call correct version of PHP scripts • Use EBR for • A/B testing • Application migration and release testing © 2009 Oracle Corporation
  • 63. Application Version 1: DB Objects Requirement: Show number of days vacation for employees SQL> create table myemp (name varchar2(10),                           hoursworked number); SQL> insert into myemp values ('alison', 200); SQL> create function vacationdaysleft(p_name in varchar2) return number as   vdl number; begin   select floor(hoursworked / 40) into vdl     from myemp where name = p_name;   return vdl; end; © 2009 Oracle Corporation
  • 64. Application Version 1: PHP Code // vacation1.php oci_set_edition('ora$base');  // OCI8 1.4 $c = oci_connect('cj','welcome','localhost/orcl'); $s = oci_parse($c,         “begin :vdl := vacationdaysleft('alison'); end;”); oci_bind_by_name($s, “:vdl”, $vdl, 15); oci_execute($s); echo “alison has “ . $vdl . ” days vacation leftn”; $ php vacation1.php alison has 5 days vacation left • © 2009 Oracle Corporation
  • 65. EBR Recap: Application Version 1 • One vacation1.php script • One vacationdaysleft stored function • One myemp table • One set of users accessing the application © 2009 Oracle Corporation
  • 66. Application Version 2: DB Schema New Requirement: Alter the vacation rate calculation SQL> create edition e2; SQL> alter session set edition = e2; SQL> create function vacationdaysleft(p_name in varchar2)    return number as    vdl number;  begin   select floor(hoursworked / 20) into vdl      from myemp where name = p_name;   return vdl; end; © 2009 Oracle Corporation
  • 67. Application Version 2: PHP Code // vacation2.php oci_set_edition('e2');  // OCI8 1.4 $c = oci_connect('cj','welcome','localhost/orcl'); $s = oci_parse($c,         “begin :vdl := vacationdaysleft('alison'); end;”); oci_bind_by_name($s, “:vdl”, $vdl, 15); oci_execute($s); echo “alison now has “ . $vdl . ” days vacation leftn”; © 2009 Oracle Corporation
  • 68. Recap: Edition Based Redefinition • Two scripts: vacation1.php and vacation2.php • Two vacationdaysleft stored functions in same schema • One myemp table • Two sets of web users running different versions concurrently $ php vacation1.php alison has 5 days vacation left $ php vacation2.php alison now has 10 days vacation left • When migration completed, use DROP EDITION • Use oci_set_edition() not ALTER SESSION in PHP © 2009 Oracle Corporation
  • 69. Oracle Database and PHP Roadmap © 2009 Oracle Corporation
  • 70. Oracle Database and PHP Roadmap • PDO_OCI • There is a disconnect between PDO_xxx users and maintainers • PDO_xxx drivers are not well maintained © 2009 Oracle Corporation
  • 71. Oracle Database and PHP Roadmap • PHP OCI8 integration with • TimesTen In Memory Database • A fast in memory, persistent DB • TimesTen In Memory Database Cache • Cache for Oracle Database • No need for separate caching logic © 2009 Oracle Corporation
  • 72. Some PHP & Oracle Books © 2009 Oracle Corporation
  • 73. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. © 2009 Oracle Corporation
  • 74. Oracle Resources Oracle Techology Network (OTN) – PHP Developer Center: otn.oracle.com/php – Free book: Underground PHP and Oracle Manual – Whitepapers, Articles, FAQs, links to blogs – PHP Extension, PHP RPMs Information – christopher.jones@oracle.com – blogs.oracle.com/opal – kuassi.mensah@oracle.com – db360.blogspot.com SQL and PL/SQL Questions – asktom.oracle.com ISVs and hardware vendors – oraclepartnernetwork.oracle.com © 2009 Oracle Corporation
  • 75. © 2009 Oracle Corporation
  • 76. Extra Slides © 2009 Oracle Corporation
  • 77. DBMS_XA: Transactions Across Requests • Oracle 11gR1 Feature • Can we use it on the web? Upgrading thick client applications? • Example from http://tinyurl.com/dbmsxaex HTTP Request #1:   rc  := DBMS_XA.XA_START(DBMS_XA_XID(123), DBMS_XA.TMNOFLAGS);   UPDATE employees SET salary=salary*1.1 WHERE employee_id = 100;   rc  := DBMS_XA.XA_END(DBMS_XA_XID(123), DBMS_XA.TMSUSPEND); HTTP Request #2:   rc  := DBMS_XA.XA_START(DBMS_XA_XID(123), DBMS_XA.TMRESUME);   SELECT salary INTO s FROM employees WHERE employee_id = 100;   rc  := DBMS_XA.XA_END(DBMS_XA_XID(123), DBMS_XA.TMSUCCESS);       HTTP Request #3:   rc  := DBMS_XA.XA_COMMIT(DBMS_XA_XID(123), TRUE); © 2009 Oracle Corporation
  • 78. Hey Look! Free Stuff • Oracle Instant Client • Easy to install • Client libraries for C, C++, Java, .Net access to a remote DB • Oracle Database Express Edition (aka “XE”) • Same code base as full database • Windows & Linux 32 bit • SQL Developer • Thick client SQL and PL/SQL development tool • Connects to MySQL too • Application Express (“Apex”) • Web based Application Development tool • Try it at http://apex.oracle.com/ © 2009 Oracle Corporation
  • 79. PHP DRCP Benchmark ● See PHP DRCP Whitepaper ● 2GB RAM ● 1 connection broker ● 100 pooled servers © 2009 Oracle Corporation