Tuning Derby Version 10.14

Tuning Derby Version 10.14

Tuning Derby Version 10.14 Derby Document build: April 6, 2018, 6:14:42 PM (PDT) Version 10.14 Tuning Derby Contents Copyright................................................................................................................................4 License................................................................................................................................... 5 About this guide....................................................................................................................9 Purpose of this guide................................................................................................9 Audience..................................................................................................................... 9 How this guide is organized.....................................................................................9 Performance tips and tricks.............................................................................................. 10 Use prepared statements with substitution parameters......................................10 Create indexes, and make sure they are being used...........................................10 Ensure that table statistics are accurate.............................................................. 10 Increase the size of the data page cache............................................................. 11 Tune the size of database pages...........................................................................11 Performance trade-offs of large pages............................................................... 12 Avoid expensive queries.........................................................................................13 Use the appropriate getXXX and setXXX methods for the type.......................... 13 Tune database booting/class loading....................................................................14 Avoid inserts in autocommit mode if possible.....................................................14 Improve the performance of table functions........................................................ 14 Configure Derby to use an in-memory database................................................. 15 Increase the concurrency of sequences............................................................... 15 Shut down the system properly.............................................................................15 Put Derby first in your classpath...........................................................................15 Tuning databases and applications..................................................................................17 Application and database design issues.............................................................. 17 Avoiding table scans of large tables................................................................... 17 Avoiding compiling SQL statements................................................................... 19 Shielding users from Derby class-loading events............................................... 21 Analyzing statement execution.............................................................................. 22 Working with RunTimeStatistics............................................................................22 Overview of RunTimeStatistics........................................................................... 22 How you use the RUNTIMESTATISTICS attribute............................................. 23 How you use the XPLAIN style...........................................................................23 Analyzing the information.................................................................................... 25 DML statements and performance....................................................................................31 Performance and optimization............................................................................... 31 Index use and access paths............................................................................... 31 Joins and performance........................................................................................36 Derby's cost-based optimization..........................................................................38 Locking and performance.......................................................................................43 Transaction-based lock escalation...................................................................... 43 Locking a table for the duration of a transaction.................................................44 Non-cost-based optimizations................................................................................44 Non-cost-based sort avoidance (tuple filtering)...................................................44 The MIN() and MAX() optimizations....................................................................46 Overriding the default optimizer behavior............................................................ 46 Selectivity and cardinality statistics................................................................................. 49 Determinations of rows scanned from disk for a table scan.............................. 49 How the optimizer determines the number of rows in a table............................. 49 Estimations of rows scanned from disk for an index scan.................................49 i Version 10.14 Tuning Derby Queries with a known search condition.............................................................. 49 Queries with an unknown search condition........................................................ 50 Statistics-based versus hard-wired selectivity.....................................................50 Selectivity from cardinality statistics....................................................................50 Selectivity from hard-wired assumptions.............................................................51 What are cardinality statistics?..............................................................................51 Working with cardinality statistics.........................................................................52 When cardinality statistics are automatically updated.........................................52 When cardinality statistics go stale..................................................................... 53 Internal language transformations....................................................................................54 Predicate transformations.......................................................................................54 BETWEEN transformations................................................................................. 55 LIKE transformations........................................................................................... 55 Simple IN predicate transformations................................................................... 56 NOT IN predicate transformations...................................................................... 58 OR transformations............................................................................................. 59 Transitive closure.................................................................................................... 59 Transitive closure on join clauses.......................................................................59 Transitive closure on search clauses..................................................................60 View transformations...............................................................................................61 View flattening..................................................................................................... 61 Predicates pushed into views or derived tables..................................................61 Subquery processing and transformations.......................................................... 62 Materialization......................................................................................................62 Flattening a subquery into a normal join.............................................................63 Flattening a subquery into an EXISTS join.........................................................65 Flattening VALUES subqueries...........................................................................66 DISTINCT elimination in IN, ANY, and EXISTS subqueries............................... 66 IN/ANY subquery transformation.........................................................................66 Outer join transformations..................................................................................... 67 Sort avoidance......................................................................................................... 67 DISTINCT elimination based on a uniqueness condition....................................67 Combining ORDER BY and DISTINCT.............................................................. 68 Combining ORDER BY and UNION................................................................... 69 Aggregate processing............................................................................................. 69 COUNT(nonNullableColumn).............................................................................. 69 Trademarks.......................................................................................................................... 70 ii Tuning Derby Apache Software FoundationTuning DerbyApache Derby 3 Tuning Derby Copyright Copyright 2004-2018 The Apache Software

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    72 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us