Materialized

Materialized views speed up request to resource “/lists/linkkeys” on method POST.

To use materialized views, it needs:

  1. After database creation(using db_create.py) check next values: USE_MATERIAL_VIEWS - 1 in config, and MATERIAL_VIEW_REFRESH_RATE - 25(default) in ./base_scripts/mv_create.py or another refresh rate that it needs to use (recommended not using refresh rate less than 5 seconds)

  2. Launch materialize views’ creation script:

    python ./base_scripts/mv_create.py
    

    If script was executed without errors, all views were created successfully.

  3. If service using postgres database copy pg_refresh.service to /etc/systemd/system folder, and execute

    systemctl daemon-reload && systemctl start pg_refresh.service
    
  4. Materialized views setup complete

To update materialized views’ refresh rate:

  1. Update MATERIAL_VIEW_REFRESH_RATE in mv_create.py

  2. If service using postgres database, execute

    systemctl start pg_refresh.service
    
  3. If service using oracle database, execute

    python ./base_scripts/mv_create.py
    
  4. Update materialized views complete. Now, service can be restarted.

To test materialized views, execute:

  1. Duplicate value of MATERIAL_VIEW_REFRESH_RATE from service config to tests’ config to the same variable

  2. Execute:

    python -m unittest tests.unittests_mv
    

    All tests should perform successfully.