lang_analyze.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html><head>
  3. <title>SQLite Query Language: ANALYZE</title>
  4. <style type="text/css">
  5. body {
  6. margin: auto;
  7. font-family: Verdana, sans-serif;
  8. padding: 8px 1%;
  9. }
  10. a { color: #45735f }
  11. a:visited { color: #734559 }
  12. .logo { position:absolute; margin:3px; }
  13. .tagline {
  14. float:right;
  15. text-align:right;
  16. font-style:italic;
  17. width:240px;
  18. margin:12px;
  19. margin-top:58px;
  20. }
  21. .toolbar {
  22. font-variant: small-caps;
  23. text-align: center;
  24. line-height: 1.6em;
  25. margin: 0;
  26. padding:1px 8px;
  27. }
  28. .toolbar a { color: white; text-decoration: none; padding: 6px 12px; }
  29. .toolbar a:visited { color: white; }
  30. .toolbar a:hover { color: #80a796; background: white; }
  31. .content { margin: 5%; }
  32. .content dt { font-weight:bold; }
  33. .content dd { margin-bottom: 25px; margin-left:20%; }
  34. .content ul { padding:0px; padding-left: 15px; margin:0px; }
  35. /* rounded corners */
  36. .se { background: url(images/se.png) 100% 100% no-repeat #80a796}
  37. .sw { background: url(images/sw.png) 0% 100% no-repeat }
  38. .ne { background: url(images/ne.png) 100% 0% no-repeat }
  39. .nw { background: url(images/nw.png) 0% 0% no-repeat }
  40. </style>
  41. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  42. </head>
  43. <body>
  44. <div><!-- container div to satisfy validator -->
  45. <a href="lang.html">
  46. <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>
  47. <p>The ANALYZE command gathers statistics about indices and stores them
  48. in a special tables in the database where the query optimizer can use
  49. them to help make better index choices.
  50. If no arguments are given, all indices in all attached databases are
  51. analyzed. If a database name is given as the argument, all indices
  52. in that one database are analyzed. If the argument is a table name,
  53. then only indices associated with that one table are analyzed.</p>
  54. <p>The default implementation stores all statistics in a single
  55. table named <b>sqlite_stat1</b>. If SQLite is compiled with the
  56. <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> option, then additional histogram data is
  57. collected and stored in <b>sqlite_stat2</b>.
  58. Future enhancements may create
  59. additional tables with the same name pattern except with the "1"
  60. or "2" changed to a different digit.</p>
  61. <p>The <a href="lang_droptable.html">DROP TABLE</a> command does
  62. not work on the <b>sqlite_stat1</b> or <b>sqlite_stat2</b> tables,
  63. but all the content of those tables can be queried using <a href="lang_select.html">SELECT</a>
  64. and can be deleted, augmented, or modified using the <a href="lang_delete.html">DELETE</a>,
  65. <a href="lang_insert.html">INSERT</a>, and <a href="lang_update.html">UPDATE</a> commands.
  66. Appropriate care should be used when changing the content of the statistics
  67. tables as invalid content can cause SQLite to select inefficient
  68. query plans. Generally speaking, one should not modify the content of
  69. the statistics tables by any mechanism other than invoking the
  70. ANALYZE command.</p>
  71. <p>Statistics gathered by ANALYZE are <u>not</u> automatically updated as
  72. the content of the database changes. If the content of the database
  73. changes significantly, or if the database schema changes, then one should
  74. consider rerunning the ANALYZE command in order to update the statistics.</p>