28
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Best Practices for Performance Part 2 .NET and Oracle Database Alex Keh Christian Shay Product Managers Server Technologies September 19, 2016

Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

  • Upload
    lykhue

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Best Practices for Performance Part 2.NET and Oracle Database

Alex KehChristian ShayProduct ManagersServer TechnologiesSeptember 19, 2016

Page 2: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Program Agenda

Caching

SQL Tuning Advisor

Oracle Performance Monitor

Q+A

1

2

3

4

2

Page 3: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

CachingODP.NET

3

Page 4: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Desirable Cache Characteristics

• Fast performance

• Easy to use/setup

• Minimize runtime resource usage

– Scalable for both client and server

• Up to date, accurate results

4

Page 5: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Better Caching Solutions

• DB responsible for change notification

– DB server = the one source of truth

• Overcomes typical disadvantages

– Network traffic – more throughput• Only generates traffic if database change occurs

– Higher scalability• Only updates if change occurs and data is read

– Timing – greater accuracy• As soon as change occurs, clients receive acknowledgement

5

Page 6: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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) – customizable cache

– TimesTen In-Memory Database

• Automatically updates/alerts client cache upon server changes

• Each meets separate caching requirements

• Server-side caches can be used with .NET

– DB In-Memory option, server result cache, etc.

6

Page 7: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle Client Result Cache

• Automatically updating query result set cache

• Benefits

– Easy to use• No code changes required

– Snapshot consistent• Cache refreshes without user intervention

– More scalability and performance• Data retrieval from client, rather than server

• No additional round trips

7

Page 8: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle Client Result Cache Updates

1. Upon data change, client receives change notification on subsequent round trip (or max lag)

– Invalidation notifications piggyback on existing client round trips

– No changes to the cache results yet

2. Cache waits for next read to refresh results– No unnecessary DB traffic

– Defers update as late as possible

• Cache entries do not timeout

– Least Recent Used algorithm

8

Page 9: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

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

Client Result Cache

Page 10: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Client Result Cache

• To use cache results, the following must match

– SQL text

– Bind values

– Session settings

• Different sessions with same user settings share cache results

– Must exist in same client process

• Different users do not share the same result sets

• One cache per machine per client process

How It Caches

10

Page 11: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle Continuous Query Notification (CQN)

• Programmatic control over cache notifications and updates

• Also known as Database Change Notification

• Benefits over Client Result Cache

– More control over how cache behavior• What if multiple DB users access the same results?

• What if only a subset of the cached data is required?

• How long should a query be cached?

• Do I want additional logic executed when the cache is refreshed?

• Requires significant customization

– CQN provides cache infrastructure

More Control Over Cache Behavior

11

Page 12: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Notification

Queue

Application

Listener

OracleCommand

OracleDependency

Data Dictionary

OnChange

Add Dependency

Execute()

Notification Request

TABLE

Data Change

Page 13: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

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

CQN

Page 14: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

When to Use These Caches

• Good use cases

– Few and mostly read-only tables

– Few rows updated for each table

– Replace app logic that checks for updates to ensure user has most up to date data

• Bad use case

– Do not use it for constantly changing data

Client Result Cache and CQN

14

Page 15: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle TimesTen In-Memory Database

• Fully featured relational database

• Oracle compatible SQL and PL/SQL

• Persistent and durable

– Transactions with ACID properties

– Flexible options for durability

• Exceptional performance– Instantaneous response time, high throughput, embeddable

• ODP.NET TimesTen provider for TimesTen DB

– Same ODP.NET APIs

Memory-Optimized Relational Database

15

Page 16: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle Performance Analyzer and SQL Tuning AdvisorOracle Developer Tools for Visual Studio

16

Page 17: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

SQL Tuning Advisor

• Included with Oracle Developer Tools for Visual Studio

• Use when designing new SQL statements

• Tune ad-hoc SQL statements in Query Window

• Tune bad SQL found by Oracle Performance Analyzer

• Use if SQL is performing poorly under load

Page 18: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

SQL Tuning Advisor

• Requirements– ADVISOR privilege

– Oracle Database license for Oracle Diagnostic Pack

– Oracle Database license for the Oracle Tuning Pack

• How to run:– Oracle Query Window “Tune SQL” button

– Oracle Performance Monitor – Tune SQL button

Page 19: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

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

SQL Tuning Advisor

Page 20: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle Performance Analyzer

• Included with Oracle Developer Tools for Visual Studio

• Detects performance issues in an application’s use of the database under load

• Requirements– SYSDBA

– Oracle Database license for Oracle Diagnostic Pack

• Can be use during testing

• Can be also used on production applications

Page 21: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Oracle Performance Analyzer

• Simple to use– Run your application

– Enter amount of time to analyze

– Press Start to start timer

– Sufficient “database time” required to get results

– View findings and actions

– Implement recommended actions

– Run Oracle Performance Analyzer again until no remaining issues

Page 22: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

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

Performance Analyzer

Page 23: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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 24: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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 – 2:30 PM Park Central – Concordia

Page 25: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Q&A

25

Page 26: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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.

26

Page 27: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

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

Page 28: Best Practices for Performance Part 2 - Oracle€¢Tune bad SQL found by Oracle Performance Analyzer •Use if SQL is performing poorly under load. ... •Best Practices for Performance

Priv microphone stops working