575
575
/* ------------------------------------------------------------------------- */
576
/* This statement provides SQLite with the necessary information about our
577
indexes to make better decisions in the query planner.
579
For every interesting index this contains a number of rows where the
580
statistics ar calculated for and then for every column in the index the
581
average number of rows with the same value in all columns left of this
582
column including the column itself.
584
See http://www.sqlite.org/fileformat2.html#stat1tab for more details.
586
The important thing here is that this tells Sqlite that the wc_id column
587
of the NODES and ACTUAL_NODE table is usually a single value, so queries
588
should use more than one column for index usage.
590
The current hints describe NODES+ACTUAL_NODE as a working copy with
591
8000 nodes in 1 a single working copy(=wc_id), 10 nodes per directory
592
and an average of 2 op-depth layers per node.
594
The number of integers must be number of index columns + 1, which is
595
verified via the test_schema_statistics() test.
597
-- STMT_INSTALL_SCHEMA_STATISTICS
598
ANALYZE sqlite_master; /* Creates empty sqlite_stat1 if necessary */
600
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
601
('NODES', 'sqlite_autoindex_NODES_1', '8000 8000 2 1');
602
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
603
('NODES', 'I_NODES_PARENT', '8000 8000 10 2 1');
604
/* Tell a lie: We ignore that 99.9% of all moved_to values are NULL */
605
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
606
('NODES', 'I_NODES_MOVED', '8000 8000 1 1');
608
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
609
('ACTUAL_NODE', 'sqlite_autoindex_ACTUAL_NODE_1', '8000 8000 1');
610
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
611
('ACTUAL_NODE', 'I_ACTUAL_PARENT', '8000 8000 10 1');
613
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
614
('LOCK', 'sqlite_autoindex_LOCK_1', '100 100 1');
616
INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES
617
('WC_LOCK', 'sqlite_autoindex_WC_LOCK_1', '100 100 1');
619
/* sqlite_autoindex_WORK_QUEUE_1 doesn't exist because WORK_QUEUE is
620
a INTEGER PRIMARY KEY AUTOINCREMENT table */
622
ANALYZE sqlite_master; /* Loads sqlite_stat1 data for query optimizer */
623
/* ------------------------------------------------------------------------- */
577
625
/* Format 20 introduces NODES and removes BASE_NODE and WORKING_NODE */