-
Notifications
You must be signed in to change notification settings - Fork 47
Database
Josh Hursey edited this page Jan 8, 2019
·
21 revisions
This page describes how to setup the MTT PostgreSQL database. PostgreSQL was chosen for a variety of reasons including performance, and advanced features such as partition tables and advanced optimizer techniques.
The MTT database schema can stress a PostgreSQL installation as a result there are a few configuration options that need to be tweaked in order for PostgreSQL to perform well in the common case.
- Turn on remote access if your webserver is not the same machine as the database machine. Do this by editing the webserver information to
data/pg_hba.confand adjusting thelisten_addressoption in thedata/postgresql.conffile. See PostgreSQL documentation on how to properly set these values. - For
VACUUMwe need to increment the Free Space Map parameters to something like the following:
max_fsm_pages = 153600
max_fsm_relations = 2000
- Outside of these options, the defaults should be fine for most users.
Some additional, per connection, options that are handy to know:
-
constraint_exclusion: This will allow the optimizer to use the check constraints on a table to include or exclude it from the search list. This is handy when searching partition tables bystart_timestampsince the check constraint on each partition table represents a slice of time that does not overlap with any other table. So this option will speedup searches on narrow time ranges.
mtt=> set constraint_exclusion = on;
-
sort_mem: This is the amount of memory that PostgreSQL allows a connection for sorting results. Since MTT relies on many levels of aggregation increasing this value can drastically improve performance. Experimentally we have found 256 MB to be a good number.
mtt=> set sort_mem = '256MB';
- MTT requires PostgreSQL 8.2 or later. We test with 8.2.4
- Create a database user named mtt. Consult PostgreSQL documentation for instructions.
- Create a database named mtt. Consult PostgreSQL documentation for instructions.
- Find the sql scripts in
$MTT_TRUNK/server/sql/. - Load in the base tables
schemas-v3.sql:
shell$ psql -d mtt
Welcome to psql 8.2.4, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
mtt=> \i schemas-v3.sql- Load stats
schemas-stats.sqland reporterschemas-reporter:
mtt=> \i schemas-stats.sql
mtt=> \i schemas-reporter.sql
- Load the indexes
schemas-indexes.sql:
mtt=> \i schemas-indexes.sql
- Create the partition tables for
mpi_install: - In the directory
$MTT_TRUNK/server/sql/supportthere exists a script calledcreate-partitions-mpi-install.pl. This script takes two (2) arguments:YYYY MM. WhereYYYYis the fully qualified year, andMMis the month (01 - 12) orXXfor all 12 months. Specifying a single month will only generate the partition tables for that month. - Use this script to generate the
mpi_installpartition tables. The following generates partition tables for 11/2006, 12/2006, and all months in 2007:
$ cd $MTT_TRUNK/server/sql/support
$ ./create-partitions-mpi-install.pl 2006 11 > mpi-install-part.sql
$ ./create-partitions-mpi-install.pl 2006 12 >> mpi-install-part.sql
$ ./create-partitions-mpi-install.pl 2007 XX >> mpi-install-part.sql- Load the partition tables into your database:
mtt=> \i mpi-install-part.sql
- Create the partition tables for
test_buildby following the same instructions as withmpi_install, but using thecreate-partitions-test-build.plscript. - Create the partition tables for
test_runby following the same instructions as withmpi_install, but using thecreate-partitions-test-run.plscript. - Now you should have the schemas in place for storing the MTT database.
Some documentation on the MTT database schema design is located in the MTT docs directory.
(0) Log in as the mpiteam user
(1) cd /mnt/data/mtt.open-mpi.org/mtt/server/sql/support
(2) less README
(3) EDIT create-partitions-test-run.pl to remove references to: bios_id, firmware_id, provision_id, harasser_id
-- OMPI DB does not have these fields so the Test Run tables will fail to load if these references are in there.
(4) ./yearly-table-update.pl 2019
(5) Insert those tables using the commands displayed to the console
instead of "psql mtt -U mtt" use the wrapper "psql-ompi" like the following:
psql-ompi -f tmp/2019-mpi-install.sql
psql-ompi -f tmp/2019-test-build.sql
psql-ompi -f tmp/2019-test-run.sql
psql-ompi -f tmp/2019-indexes.sql
psql-ompi -f tmp/2019-triggers.sql