- C Merge\sin\sall\schanges\sthrough\sthe\s3.7.8\srelease.
- D 2011-09-19T20:36:42.908
-C Minor\scomment\schange\sin\sthe\sdescription\sof\sthe\sdifferent\smemory\sallocator\noptions.\s\sNo\schanges\sto\scode.
-D 2011-09-19T20:56:59.410
++C Pull\sin\sthe\slatest\schanges\sfrom\strunk.\s\sUpdate\sthe\sSTAT3\sdocumentation.
++D 2011-09-21T00:09:41.245
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
F src/alter.c ac80a0f31189f8b4a524ebf661e47e84536ee7f5
- F src/analyze.c 3fbffcfbc606d73fa996ded1f874eddffbb06d09
-F src/analyze.c a425d62e8fa9ebcb4359ab84ff0c62c6563d2e2a
++F src/analyze.c 002e085428c9b2dda5b25f43539178d31c124525
F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c 28a4fe55327ff708bfaf9d4326d02686f7a553c3
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c d9b7d20b0365f80761846f00ef3638d4b33eeaf2
F src/shell.c 13fe2aeddc3cc90d6a273831d1f63736d1596f81
-F src/sqlite.h.in 0a6c9c23337fd1352c5c75a613ff9533aa7d91cb
+F src/sqlite.h.in 3f531daa04457e83bc13765c98c06c7d71c27fa5
F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93
- F src/sqliteInt.h dea1be7eccbc4c4e28fffebae19ab5e2af2b3a26
-F src/sqliteInt.h 76d81cd9da0618b231398bfcf90556e971972fca
++F src/sqliteInt.h 6cb04e5216d68becf18fd4a4a6d47ec07f33219c
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9
F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
- F src/where.c 4d7321662f1d23c73fce7245470f4a41c18665df
-F src/where.c b641d399cfd8588d0e20d9790d1582b663a732a8
++F src/where.c da04df6f003024bd217da9afb369e751417e07da
F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
-P 3e0da808d2f5b4d12046e05980ca04578f581177
-R 8185767b36f8ee5089cf1856ba34ec13
+F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
- P 51908c8f2bc6c086570f7493a29b096f0a40ce34 3e0da808d2f5b4d12046e05980ca04578f581177
- R 33df24e64f9adc713ca6be5c23008117
++P 9607600b6ca9b546dd248982fd8e8d64f708be5c 36be31ff0af7f811fe2c6f7e26f058cffb7257e1
++R bd162fa2b501bed3d79b1607f9710e81
U drh
- Z 7823e3ddec646924dd88293936a2470a
-Z dd5a6c14bafead231702b31c9079bdda
++Z 642a2c81deaec7b7de912d100473111b
**
*************************************************************************
** This file contains code associated with the ANALYZE command.
- ** is between 3.6.18 and 3.7.7, inclusive, and unless SQLite is compiled
+**
+** The ANALYZE command gather statistics about the content of tables
+** and indices. These statistics are made available to the query planner
+** to help it make better decisions about how to perform queries.
+**
+** The following system tables are or have been supported:
+**
+** CREATE TABLE sqlite_stat1(tbl, idx, stat);
+** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);
+** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);
+**
+** Additional tables might be added in future releases of SQLite.
+** The sqlite_stat2 table is not created or used unless the SQLite version
- ** created and used by SQLite versions after 2011-08-09 with
++** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled
+** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
+** The sqlite_stat2 table is superceded by sqlite_stat3, which is only
- ** 3.6.18 and 3.7.7. The "stat2" table contains additional information
++** created and used by SQLite versions 3.7.9 and later and with
+** SQLITE_ENABLE_STAT3 defined. The fucntionality of sqlite_stat3
+** is a superset of sqlite_stat2.
+**
+** Format of sqlite_stat1:
+**
+** There is normally one row per index, with the index identified by the
+** name in the idx column. The tbl column is the name of the table to
+** which the index belongs. In each such row, the stat column will be
+** a string consisting of a list of integers. The first integer in this
+** list is the number of rows in the index and in the table. The second
+** integer is the average number of rows in the index that have the same
+** value in the first column of the index. The third integer is the average
+** number of rows in the index that have the same value for the first two
+** columns. The N-th integer (for N>1) is the average number of rows in
+** the index which have the same value for the first N-1 columns. For
+** a K-column index, there will be K+1 integers in the stat column. If
+** the index is unique, then the last integer will be 1.
+**
+** The list of integers in the stat column can optionally be followed
+** by the keyword "unordered". The "unordered" keyword, if it is present,
+** must be separated from the last integer by a single space. If the
+** "unordered" keyword is present, then the query planner assumes that
+** the index is unordered and will not use the index for a range query.
+**
+** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat
+** column contains a single integer which is the (estimated) number of
+** rows in the table identified by sqlite_stat1.tbl.
+**
+** Format of sqlite_stat2:
+**
+** The sqlite_stat2 is only created and is only used if SQLite is compiled
+** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between
- ** The format of the sqlite_stat3 table is similar to the format for
- ** the sqlite_stat2 table, with the following changes: (1)
- ** The sampleno column is removed. (2) Every sample has nEq, nLt, and nDLt
- ** columns which hold the approximate number of rows in the table that
- ** exactly match the sample, the approximate number of rows with values
- ** less than the sample, and the approximate number of distinct key values
- ** less than the sample, respectively. (3) The number of samples can vary
- ** from one table to the next; the sample count does not have to be
- ** exactly 10 as it is with sqlite_stat2.
- **
++** 3.6.18 and 3.7.8. The "stat2" table contains additional information
+** about the distribution of keys within an index. The index is identified by
+** the "idx" column and the "tbl" column is the name of the table to which
+** the index belongs. There are usually 10 rows in the sqlite_stat2
+** table for each index.
+**
+** The sqlite_stat2 entries for an index that have sampleno between 0 and 9
+** inclusive are samples of the left-most key value in the index taken at
+** evenly spaced points along the index. Let the number of samples be S
+** (10 in the standard build) and let C be the number of rows in the index.
+** Then the sampled rows are given by:
+**
+** rownumber = (i*C*2 + C)/(S*2)
+**
+** For i between 0 and S-1. Conceptually, the index space is divided into
+** S uniform buckets and the samples are the middle row from each bucket.
+**
+** The format for sqlite_stat2 is recorded here for legacy reference. This
+** version of SQLite does not support sqlite_stat2. It neither reads nor
+** writes the sqlite_stat2 table. This version of SQLite only supports
+** sqlite_stat3.
+**
+** Format for sqlite_stat3:
+**
+** The sqlite_stat3 is an enhancement to sqlite_stat2. A new name is
+** used to avoid compatibility problems.
+**
++** The format of the sqlite_stat3 table is similar to the format of
++** the sqlite_stat2 table. There are multiple entries for each index.
++** The idx column names the index and the tbl column is the table of the
++** index. If the idx and tbl columns are the same, then the sample is
++** of the INTEGER PRIMARY KEY. The sample column is a value taken from
++** the left-most column of the index. The nEq column is the approximate
++** number of entires in the index whose left-most column exactly matches
++** the sample. nLt is the approximate number of entires whose left-most
++** column is less than the same. The nDLt column is the approximate
++** number of distinct left-most entries in the index that are less than
++** the same.
++**
++** Future versions of SQLite might change to store a string containing
++** multiple integers values in the nDLt column of sqlite_stat3. The first
++** integer will be the number of prior index entires that are distinct in
++** the left-most column. The second integer will be the number of prior index
++** entries that are distinct in the first two columns. The third integer
++** will be the number of prior index entries that are distinct in the first
++** three columns. And so forth. With that extension, the nDLt field is
++** similar in function to the sqlite_stat1.stat field.
++**
++** There can be an arbitrary number of sqlite_stat3 entries per index.
+** The ANALYZE command will typically generate sqlite_stat3 tables
+** that contain between 10 and 40 samples which are distributed across
+** the key space, though not uniformly, and which include samples with
+** largest possible nEq values.
*/
#ifndef SQLITE_OMIT_ANALYZE
#include "sqliteInt.h"