35

Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming
Page 2: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Best Practices for Performance Part 1.NET and Oracle Database

Alex KehChristian ShayProduct ManagersServer TechnologiesSeptember 19, 2016

Page 3: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

Optimization Process

ODP.NET Performance

Part 2 Preview

Q+A

1

2

3

4

3

Page 4: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Optimization ProcessEnd to End Oracle .NET performance management

4

Page 5: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Oracle .NET Application PerformanceOptimization Steps

• .NET data access tuning

– Use ODP.NET best practices

• SQL tuning

– Use SQL Tuning Advisor in Visual Studio

• Database tuning under real world conditions–Oracle Performance Analyzer in Visual Studio detects issues you have missed

–May need to modify application based on findings

– Can be used during testing phase or production

Page 6: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Optimizing ODP.NET PerformanceODP.NET

6

Page 7: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

General

• Close/Dispose all ODP.NET objects explicitly

– Garbage collector cannot reliably implicitly dispose objects under heavy load• May see increasing memory usage

• Can use “Using” statement instead

• Recommended for all ODP.NET objects

7

All ODP.NET Objects

Page 8: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Connections

• Use connection pooling

–Min Pool Size = # connections at steady state or average load

–Max Pool Size = # connections at maximum capacity• Min and Max Pool Size always obeyed over other CP attributes

– See documentation for connection pooling parameter options

• ODP.NET performance counters

–Monitor with Windows Performance Monitor

–More granularity in monitoring – New in ODAC 12c• Monitor at app domain, pool, or DB instance level

– See documentation for details on how to enable

Confidential – Oracle Internal/Restricted/Highly Restricted 8

Page 9: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Connections

• Connection pool tagging

– Identify connections with specific settings using tags• i.e. American users or French users

• i.e. gold customers or platinum customers

–ODP.NET searches pool for matching tag and retrieves that connection to be opened

– No round trips to set session settings for every new connection

• Database Resident Connection Pooling (DRCP)

– Server side connection pool that optimizes memory use

– Pools "dedicated" servers

New in ODAC 12.2

Confidential – Oracle Internal/Restricted/Highly Restricted 9

Page 10: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

New .NET Features

• OOW session: What’s New for .NET Developers in Oracle Database

– Thursday, Sep 22, 1:15 PM

– Park Central Hotel – Concordia Room

Upcoming Session

10

Page 11: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Connection Management

• Fast Application Notification (FAN) infrastructure

–ODP.NET 12c (mostly) uses Oracle Notification Service (ONS)

–ONS delivers FAN events faster than previous AQ infrastructure

• Run-time connection load balancing– Automated load balancing at connection dispense time• Better performance because dispense based on real-time load

– Set “Load Balancing = true” in connection string• Now the default in ODP.NET 12.2

RAC, Data Guard, GoldenGate, and GDS

11

Page 12: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Connection Management

• Fast Connection Failover

– Severed connections and returned connections automatically removed from pool• End users no longer receive invalid connections after a failure

–Works for planned and unplanned outages

– Set “HA Events = true” in connection string• Now the default in ODP.NET 12.2

• For Data Guard switchover

–ODP.NET ServiceRelocationConnectionTimeout setting pauses incoming connection requests until standby is up• End users will not see connection timeout errors

High Availability

12

Page 13: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

More HA Connection Management

• OOW session: Best Practices for High Availability: .NET and Oracle Database session

– Thursday, Sep 22, 2:30 PM

– Park Central Hotel – Concordia Room

13

Page 14: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Oracle Client Performance Tips

• Server side connection pooling types

– Dedicated server

– Shared server

– Database Resident Connection Pooling (DRCP)• New for ODAC 12.2c

• Connect time load balancing

– Connects to least loaded instance/database when pool is created

Tuning Options Set Outside ODP.NET

14

Page 15: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Oracle Client Performance Tips

• Oracle Net Services packet size

–Optimize connection’s Session Data Unit (SDU) size

– Increase “DEFAULT_SDU_SIZE” in SQLNET.ORA or “SDU” in TNSNAMES.ORA

– If SDU settings between client and server do not match, lower value will be used

• OOW session: Best Practices for Oracle Database Performance on Windows

–Monday, Sep 19, 5:30 PM

– Park Central Hotel – Olympic Room

Tuning Options Set Outside ODP.NET

15

Page 16: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Commands

• Prevents re-parsing of frequently executed statements

–Works with SQL and PL/SQL statements

• Improves subsequent command executions

– Literal value changes forces a re-parse and re-optimization

– Literal values should become bind variables

• Executed statements stored in Oracle shared pool

– Re-parsing and re-optimization uses CPU and requires shared pool locks

Bind Variables

16

Page 17: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Commands

• Retains previously parsed statement in shared pool

– Prevents repeated parsing in server

• Caches most recently used statements

–Works with SQL and PL/SQL statements

– Best with bind variables

• Self-tuned cache size – on by default

– No code changes needed

Statement Caching

17

Page 18: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Commands

• Control how much data is retrieved per DB roundtrip

– Too much data retrieved – excessive client-side memory used

– Too little data retrieved – additional round trips

• Use OracleCommand.RowSize and OracleDataReader.FetchSize to control result size– RowSize populated after statement execution• Can be set dynamically at run-time

– FetchSize can be set as multiple of RowSize

Data Retrieval

18

Page 19: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

D E M O N S T R A T I O N

Fetch Size and Row Size

Page 20: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Commands

• Statement batching

– Use OracleDataAdapter.UpdateBatchSize to batch updates from DataSet

– Execute multiple commands in one DB roundtrip• By using anonymous PL/SQL

Data Updates

20

Page 21: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Commands

• PL/SQL associative arrays

– Pass large amounts of data between .NET and DB of the same data type

• Use parameter array binding

– Useful if executing the same statement multiple times

– Bind variables are the same, variable values can be different

–One execution for each element in the bound array

Mass Data Movement with Arrays

21

Page 22: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Promotable Transactions

• Promote local transactions to distributed at run time

– Better application performance

– Lower resource usage

• On by default

• Requirements– Requires Oracle Database 11g (11.1.0.7+) and ODAC 11.1.0.7.20+

– Subsequent connections to any other version or database

22

Page 23: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

REF Cursors

• OracleRefCursor class

• Defers result set retrieval until needed

• Retrieve data as needed

– Control data retrieved via FetchSize

– Fill a DataSet with just a portion of the REF Cursor result

• Usage– Can create REF Cursors as part of an anonymous PL/SQL block

– Can return REF Cursors from stored procedures

– Can pass REF Cursors to database as input stored procedure parameters

23

Page 24: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

SecureFiles and LOBs

• Data retrieval options

– Control amount of data returned with OracleCommand.InitialLOBFetchSize

– Retrieve a chunk using OracleClob and OracleBlob classes Read method• Use Search method to find data to be retrieved

• Update/Insert/Delete SQL statements acting on LOBs–Modify LOB without retrieving the data to the client side• Uses LOB locator

• VARCHAR2, NVARCHAR2, and RAW now support up to 32 KB

–ODP.NET 12c and Oracle DB 12c enhancement

24

Page 25: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Coming Up in Best Practices Part 2Thursday, Sep 22, 10:45 a.m. | Marriott Marquis - Salon 10/11

25

Page 26: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Oracle .NET Caching Solutions

• Oracle .NET client-side DB caches

– Client Result Cache

– Continuous Query Notification (CQN)

– TimesTen In-Memory Database

26

Page 27: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Tuning with Oracle Developer Tools For Visual Studio

• Oracle Performance Analyzer SQL Tuning Advisor

Page 28: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Come See the SQL……I mean, Sequel ;-)

• OOW session: Best Practices for Performance Part 2: .NET and Oracle Database

– Thursday, Sep 22, 10:45 AM

–Marriott Marquis Hotel - Salon 10/11 Rooms

Coming to an OpenWorld Near You

28

Page 29: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Additional Oracle .NET Resources

OTNotn.oracle.com/dotnet

Twittertwitter.com/OracleDOTNET

YouTubeyoutube.com/OracleDOTNETTeam

[email protected] and [email protected]

Page 30: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Upcoming .NET Sessions

• Meet the Oracle Programming and Scripting Experts – Tuesday – 6:15 PM Moscone South - 310

• Best Practices for Performance Part 2: .NET and Oracle Database– Thursday- 10:45 AM Marriott Marquis - Salon 10/11

• PL/SQL Programming for .NET Developers: Tips, Tricks, and Debugging– Thursday – 12:00 PM Marriott Marquis - Salon 10/11

• What’s New for .NET Developers in Oracle Database

– Thursday – 1:15 PM Park Central - Concordia

• Best Practices for High Availability: .NET and Oracle Database

• Thursday – 1:15 PM Park Central – Concordia

Page 31: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Demogrounds

• Visit Windows experts at the Demogrounds:Oracle Database 12c: .NET Development and Windows Platform Integration– Today through Wednesday

– Moscone South Exhibition Hall, far left by walkway

– Booth SDB-003

Page 32: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Q&A

32

Page 33: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement

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.

33

Page 34: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 34

Page 35: Best Practices for Performance - Oracle · •Best Practices for Performance Part 2: .NET and Oracle Database –Thursday- 10:45 AM Marriott Marquis - Salon 10/11 •PL/SQL Programming