| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Using Multiversion Concurrency Control</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Getting Started with the Oracle Berkeley DB SQL APIs" /> |
| 10 | <link rel="up" href="dbfeatures.html" title="Chapter 3. Berkeley DB Features" /> |
| 11 | <link rel="prev" href="dbfeatures.html" title="Chapter 3. Berkeley DB Features" /> |
| 12 | <link rel="next" href="selectpage_size.html" title="Selecting the Page Size" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Using Multiversion Concurrency Control</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="dbfeatures.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 3. Berkeley DB Features</th> |
| 26 | <td width="20%" align="right"> <a accesskey="n" href="selectpage_size.html">Next</a></td> |
| 27 | </tr> |
| 28 | </table> |
| 29 | <hr /> |
| 30 | </div> |
| 31 | <div class="sect1" lang="en" xml:lang="en"> |
| 32 | <div class="titlepage"> |
| 33 | <div> |
| 34 | <div> |
| 35 | <h2 class="title" style="clear: both"><a id="mvcc"></a>Using Multiversion Concurrency Control</h2> |
| 36 | </div> |
| 37 | </div> |
| 38 | </div> |
| 39 | <p> |
| 40 | Multiversion Concurrency Control (MVCC) enables snapshot |
| 41 | isolation. Snapshot isolation means that whenever a |
| 42 | transaction would take a read lock on a page, it |
| 43 | makes a copy of the page instead, and then performs its |
| 44 | operations on that copied page. This frees other writers |
| 45 | from blocking due to a read locks held by other |
| 46 | transactions. |
| 47 | </p> |
| 48 | <p> |
| 49 | You should use snapshot isolation whenever you have a lot |
| 50 | of read-only transactions operating at the same time that |
| 51 | read-write transactions. In this case, snapshot isolation |
| 52 | will improve transaction throughput, albeit at the cost of |
| 53 | greater resource usage. |
| 54 | </p> |
| 55 | <p> |
| 56 | MVCC is described in more detail in |
| 57 | <a href="../programmer_reference/transapp_read.html#snapshot_isolation" class="olink">Snapshot Isolation.</a> |
| 58 | </p> |
| 59 | <p> |
| 60 | To use MVCC, you must enable it before you access any |
| 61 | database tables. Once MVCC is enabled, you can turn |
| 62 | snapshot isolation on and off at anytime during the life of |
| 63 | your application. |
| 64 | </p> |
| 65 | <p> |
| 66 | To turn MVCC on, use: |
| 67 | </p> |
| 68 | <p> |
| 69 | <span class="bold"><strong>PRAGMA multiversion</strong></span> = on | off; |
| 70 | </p> |
| 71 | <p> |
| 72 | This PRAGMA must be enabled before you access any database |
| 73 | tables during your application runtime, or an error is |
| 74 | returned. Turning MVCC on automatically enables snapshot |
| 75 | isolation. By default MVCC is turned off. |
| 76 | </p> |
| 77 | <p> |
| 78 | Once MVCC is enabled, you can turn snapshot isolation on |
| 79 | and off using: |
| 80 | </p> |
| 81 | <p> |
| 82 | <span class="bold"><strong>PRAGMA snapshot_isolation</strong></span> = on | off; |
| 83 | </p> |
| 84 | <p> |
| 85 | This PRAGMA can be used at any time during the life of your |
| 86 | application <span class="emphasis"><em>after</em></span> MVCC has been turned |
| 87 | on. If you attempt to enable or disable snapshot isolation |
| 88 | before MVCC is enabled, an error is returned. |
| 89 | </p> |
| 90 | </div> |
| 91 | <div class="navfooter"> |
| 92 | <hr /> |
| 93 | <table width="100%" summary="Navigation footer"> |
| 94 | <tr> |
| 95 | <td width="40%" align="left"><a accesskey="p" href="dbfeatures.html">Prev</a> </td> |
| 96 | <td width="20%" align="center"> |
| 97 | <a accesskey="u" href="dbfeatures.html">Up</a> |
| 98 | </td> |
| 99 | <td width="40%" align="right"> <a accesskey="n" href="selectpage_size.html">Next</a></td> |
| 100 | </tr> |
| 101 | <tr> |
| 102 | <td width="40%" align="left" valign="top">Chapter 3. Berkeley DB Features </td> |
| 103 | <td width="20%" align="center"> |
| 104 | <a accesskey="h" href="index.html">Home</a> |
| 105 | </td> |
| 106 | <td width="40%" align="right" valign="top"> Selecting the Page Size</td> |
| 107 | </tr> |
| 108 | </table> |
| 109 | </div> |
| 110 | </body> |
| 111 | </html> |