1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html><head>
- <title>SQLite Query Language: ANALYZE</title>
- <style type="text/css">
- body {
- margin: auto;
- font-family: Verdana, sans-serif;
- padding: 8px 1%;
- }
- a { color: #45735f }
- a:visited { color: #734559 }
- .logo { position:absolute; margin:3px; }
- .tagline {
- float:right;
- text-align:right;
- font-style:italic;
- width:240px;
- margin:12px;
- margin-top:58px;
- }
- .toolbar {
- font-variant: small-caps;
- text-align: center;
- line-height: 1.6em;
- margin: 0;
- padding:1px 8px;
- }
- .toolbar a { color: white; text-decoration: none; padding: 6px 12px; }
- .toolbar a:visited { color: white; }
- .toolbar a:hover { color: #80a796; background: white; }
- .content { margin: 5%; }
- .content dt { font-weight:bold; }
- .content dd { margin-bottom: 25px; margin-left:20%; }
- .content ul { padding:0px; padding-left: 15px; margin:0px; }
- /* rounded corners */
- .se { background: url(images/se.png) 100% 100% no-repeat #80a796}
- .sw { background: url(images/sw.png) 0% 100% no-repeat }
- .ne { background: url(images/ne.png) 100% 0% no-repeat }
- .nw { background: url(images/nw.png) 0% 0% no-repeat }
- </style>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
- </head>
- <body>
- <div><!-- container div to satisfy validator -->
- <a href="lang.html">
- <h2 align="center">SQL As Understood By SQLite</h2></a><h1>ANALYZE</h1><h4><a href="syntaxdiagrams.html#analyze-stmt">analyze-stmt:</a></h4><blockquote> <img alt="syntax diagram analyze-stmt" src="images/syntax/analyze-stmt.gif"></img> </blockquote>
- <p>The ANALYZE command gathers statistics about indices and stores them
- in a special tables in the database where the query optimizer can use
- them to help make better index choices.
- If no arguments are given, all indices in all attached databases are
- analyzed. If a database name is given as the argument, all indices
- in that one database are analyzed. If the argument is a table name,
- then only indices associated with that one table are analyzed.</p>
- <p>The default implementation stores all statistics in a single
- table named <b>sqlite_stat1</b>. If SQLite is compiled with the
- <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> option, then additional histogram data is
- collected and stored in <b>sqlite_stat2</b>.
- Future enhancements may create
- additional tables with the same name pattern except with the "1"
- or "2" changed to a different digit.</p>
- <p>The <a href="lang_droptable.html">DROP TABLE</a> command does
- not work on the <b>sqlite_stat1</b> or <b>sqlite_stat2</b> tables,
- but all the content of those tables can be queried using <a href="lang_select.html">SELECT</a>
- and can be deleted, augmented, or modified using the <a href="lang_delete.html">DELETE</a>,
- <a href="lang_insert.html">INSERT</a>, and <a href="lang_update.html">UPDATE</a> commands.
- Appropriate care should be used when changing the content of the statistics
- tables as invalid content can cause SQLite to select inefficient
- query plans. Generally speaking, one should not modify the content of
- the statistics tables by any mechanism other than invoking the
- ANALYZE command.</p>
- <p>Statistics gathered by ANALYZE are <u>not</u> automatically updated as
- the content of the database changes. If the content of the database
- changes significantly, or if the database schema changes, then one should
- consider rerunning the ANALYZE command in order to update the statistics.</p>
|