Running the example
The complete demo used to generate these examples is included with this book's sample files, and it was transformed into text by running the example like the following:
$ psql -e -f indextest.sql > indextest.out
You might want to tinker with the source code or set up and try running it yourself in this way. The general technique used—create sample data, execute a query, gather usage statistics around it—is a very common one used for iteratively improving a given query as you tweak either its indexing or database parameters
To keep complete control over what's going on while running this demo, the autovacuum
parameter was first turned off in the postgresql.conf
file:
$ psql -c "show autovacuum" autovacuum ------------ off
If you have autovacuum
turned on, you'll see slightly different results. It will do the appropriate ANALYZE
work needed to make things work right automatically, instead of waiting for the manual execution...