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

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
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우PgDay.Seoul
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsManav Prasad
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder
 
Practical non blocking microservices in java 8
Practical non blocking microservices in java 8Practical non blocking microservices in java 8
Practical non blocking microservices in java 8Michal Balinski
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해beom kyun choi
 
Percona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationPercona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationmysqlops
 
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Niels de Bruijn
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread poolsmaksym220889
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuingGurpreet singh
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automationCarlos Sierra
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1SolarWinds
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQLKyle Hailey
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and TomorrowVMware Tanzu
 
Spring boot Under Da Hood
Spring boot Under Da HoodSpring boot Under Da Hood
Spring boot Under Da HoodMichel Schudel
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바NeoClova
 
Programmazione Funzionale per tutti
Programmazione Funzionale per tuttiProgrammazione Funzionale per tutti
Programmazione Funzionale per tuttiSalvatore Sorrentino
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder
 

What's hot (20)

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
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
 
Practical non blocking microservices in java 8
Practical non blocking microservices in java 8Practical non blocking microservices in java 8
Practical non blocking microservices in java 8
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해
 
Percona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationPercona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimization
 
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuing
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automation
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQL
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and Tomorrow
 
Spring boot Under Da Hood
Spring boot Under Da HoodSpring boot Under Da Hood
Spring boot Under Da Hood
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
 
Programmazione Funzionale per tutti
Programmazione Funzionale per tuttiProgrammazione Funzionale per tutti
Programmazione Funzionale per tutti
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata Migrations
 
SQLd360
SQLd360SQLd360
SQLd360
 
Code injection
Code injectionCode injection
Code injection
 

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 using metasploit
Hacking oracle using metasploitHacking oracle using metasploit
Hacking oracle using metasploit
 
Hacking Oracle Web Applications With Metasploit
Hacking Oracle Web Applications With MetasploitHacking Oracle Web Applications With Metasploit
Hacking Oracle Web Applications With 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

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

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