Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up PostGIS database with with synchronous_commit=off and more #94

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anthonyfok
Copy link
Member

Fixes #77


Not quite ready yet:

  • ps auxwww does shows a postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=off process, but do need to verify if the command-line options actually reach the PostgreSQL server
  • Need to understand how to read the logs
  • I moved my /var/lib/docker/volumes where the PostgreSQL database resides to an NFS mount (for no particularly good reason, in retrospect), so that may affect the benchmark.

@anthonyfok
Copy link
Member Author

Some rudimentary benchmarks:

TODO

Before

foka@debian:~/OpenDRR/opendrr-api/logs$ cat '2021-03-19 22:38:56-06:00.log' | egrep -v '(elasticsearch|pygeoapi)' | egrep '(Z  [A-Z]|Z Import|Z   -)'
python-opendrr_1         | 2021-03-19T21:08:37.065068202Z  Importing Census Boundaries
python-opendrr_1         | 2021-03-19T21:08:37.065074138Z   - ogr2ogr: Importing boundaries/Geometry_ADAUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:08:56.282382549Z   - ogr2ogr: Importing boundaries/Geometry_CANADA.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:09:03.199286331Z   - ogr2ogr: Importing boundaries/Geometry_CDUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:09:13.105887713Z   - ogr2ogr: Importing boundaries/Geometry_CSDUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:09:31.459382703Z   - ogr2ogr: Importing boundaries/Geometry_DAUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:10:18.700612079Z   - ogr2ogr: Importing boundaries/Geometry_ERUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:10:36.128691930Z   - ogr2ogr: Importing boundaries/Geometry_FSAUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:10:52.875484469Z   - ogr2ogr: Importing boundaries/Geometry_PRUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:11:04.812921179Z   - ogr2ogr: Importing boundaries/Geometry_SAUID.gpkg into opendrr...
python-opendrr_1         | 2021-03-19T21:13:34.485719821Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-03-19T21:17:57.852563559Z  Importing Physical Exposure Model into PostGIS
python-opendrr_1         | 2021-03-19T21:20:29.848448885Z   - psql: Running Create_table_canada_exposure.sql...
python-opendrr_1         | 2021-03-19T21:21:25.235162193Z   - psql: Running Create_table_canada_site_exposure_ste.sql...
python-opendrr_1         | 2021-03-19T21:21:25.524153946Z  Importing VS30 Model into PostGIS...
python-opendrr_1         | 2021-03-19T21:22:35.921673136Z   - psql: Running Create_table_vs_30_CAN_site_model.sql...
python-opendrr_1         | 2021-03-19T21:22:36.207335893Z   - psql: Running Create_table_vs_30_CAN_site_model_xref.sql...
python-opendrr_1         | 2021-03-19T21:22:36.393234165Z  Importing Census Data
python-opendrr_1         | 2021-03-19T21:24:00.505067203Z   - psql: Running Create_table_2016_census_v3.sql...
python-opendrr_1         | 2021-03-19T21:24:03.855851143Z  Importing Sovi
python-opendrr_1         | 2021-03-19T21:25:25.145609006Z   - psql: Running Create_table_sovi_index_canada_v2.sql...
python-opendrr_1         | 2021-03-19T21:25:25.781569103Z   - psql: Running Create_table_sovi_census_canada.sql...
python-opendrr_1         | 2021-03-19T21:25:26.534662863Z  Importing LUTs
python-opendrr_1         | 2021-03-19T21:25:27.551131771Z   - psql: Running Create_collapse_probability_table.sql...
python-opendrr_1         | 2021-03-19T21:25:29.688518868Z   - psql: Running Create_retrofit_costs_table.sql...
python-opendrr_1         | 2021-03-19T21:25:31.752911541Z  Importing GHSL
python-opendrr_1         | 2021-03-19T21:26:14.822894470Z   - psql: Running Create_table_GHSL.sql...
python-opendrr_1         | 2021-03-19T21:26:15.110029886Z  Importing MH Intensity
python-opendrr_1         | 2021-03-19T21:26:37.610401742Z   - psql: Running Create_table_mh_intensity_canada_v2.sql...
python-opendrr_1         | 2021-03-19T21:26:37.903656619Z   - psql: Running Create_table_mh_thresholds.sql...
python-opendrr_1         | 2021-03-19T21:33:48.008346743Z   - psql: Running Create_all_tables_update.sql...
python-opendrr_1         | 2021-03-19T22:04:21.032448898Z   - psql: Running Create_site_exposure_to_building_and_sauid.sql...
python-opendrr_1         | 2021-03-19T22:14:33.293187608Z   - psql: Running Create_table_vs_30_BC_CAN_model_update_site_exposure.sql...
python-opendrr_1         | 2021-03-19T22:16:45.272521072Z  Generate Indicators
python-opendrr_1         | 2021-03-19T22:16:45.272903257Z   - psql: Running Create_physical_exposure_building_indicators_PhysicalExposure.sql...
python-opendrr_1         | 2021-03-19T22:16:55.940133609Z   - psql: Running Create_physical_exposure_sauid_indicators_view_PhysicalExposure.sql...
python-opendrr_1         | 2021-03-19T22:17:01.736903719Z   - psql: Running Create_physical_exposure_building_indicators_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-03-19T22:17:02.312653360Z   - psql: Running Create_physical_exposure_sauid_indicators_view_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-03-19T22:17:02.648834333Z   - psql: Running Create_physical_exposure_site_level_indicators_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-03-19T22:17:03.185032697Z   - psql: Running Create_risk_dynamics_indicators.sql...
python-opendrr_1         | 2021-03-19T22:17:07.640914346Z   - psql: Running Create_social_vulnerability_sauid_indicators_SocialFabric.sql...
python-opendrr_1         | 2021-03-19T22:17:11.203817521Z   - psql: Running Create_MH_risk_sauid_ALL.sql...
python-opendrr_1         | 2021-03-19T22:17:16.920476552Z Importing Raw PSRA Tables
python-opendrr_1         | 2021-03-19T22:51:51.469148828Z   - psql: Running psra_0.create_psra_schema.sql...
python-opendrr_1         | 2021-03-19T23:58:07.293397249Z  Importing scenario outputs into PostGIS...
python-opendrr_1         | 2021-03-20T01:09:00.481000153Z Importing Shakemap
python-opendrr_1         | 2021-03-20T01:33:29.803464789Z  Importing Rupture Model
python-opendrr_1         | 2021-03-20T01:33:44.778793333Z  Generating indicator views...

boundaries populated with database dump:

foka@debian:~/OpenDRR/opendrr-api/logs$ cat '2021-04-27 23:35:14-06:00.log' | egrep -v '(elasticsearch|pygeoapi)' | egrep '(Z  [A-Z]|Z Import|Z   -)'
python-opendrr_1         | 2021-04-28T01:39:02.189832423Z  Importing Census Boundaries
python-opendrr_1         | 2021-04-28T01:42:10.983191153Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-04-28T01:43:24.787709256Z  Importing Physical Exposure Model into PostGIS
python-opendrr_1         | 2021-04-28T01:53:05.309263421Z   - psql: Running Create_table_canada_exposure.sql...
python-opendrr_1         | 2021-04-28T01:57:08.565649483Z   - psql: Running Create_table_canada_site_exposure_ste.sql...
python-opendrr_1         | 2021-04-28T01:57:08.936247124Z  Importing VS30 Model into PostGIS...
python-opendrr_1         | 2021-04-28T01:59:11.345268511Z   - psql: Running Create_table_vs_30_CAN_site_model.sql...
python-opendrr_1         | 2021-04-28T01:59:11.434928204Z   - psql: Running Create_table_vs_30_CAN_site_model_xref.sql...
python-opendrr_1         | 2021-04-28T01:59:11.514563388Z  Importing Census Data
python-opendrr_1         | 2021-04-28T02:02:02.199295933Z   - psql: Running Create_table_2016_census_v3.sql...
python-opendrr_1         | 2021-04-28T02:02:02.337880964Z  Importing Sovi
python-opendrr_1         | 2021-04-28T02:04:50.235579656Z   - psql: Running Create_table_sovi_index_canada_v2.sql...
python-opendrr_1         | 2021-04-28T02:04:50.338772495Z   - psql: Running Create_table_sovi_census_canada.sql...
python-opendrr_1         | 2021-04-28T02:04:50.431947063Z   - psql: Running Create_table_sovi_thresholds.sql...
python-opendrr_1         | 2021-04-28T02:04:50.515699709Z  Importing LUTs
python-opendrr_1         | 2021-04-28T02:04:51.456530698Z   - psql: Running Create_collapse_probability_table.sql...
python-opendrr_1         | 2021-04-28T02:04:52.469202309Z   - psql: Running Create_retrofit_costs_table.sql...
python-opendrr_1         | 2021-04-28T02:04:52.560167124Z  Importing GHSL
python-opendrr_1         | 2021-04-28T02:05:29.345018574Z   - psql: Running Create_table_GHSL.sql...
python-opendrr_1         | 2021-04-28T02:05:29.430546559Z  Importing MH Intensity
python-opendrr_1         | 2021-04-28T02:05:39.991043432Z  Importing Hazard Threat Thresholds
python-opendrr_1         | 2021-04-28T02:05:40.981257482Z   - psql: Running Create_table_mh_intensity_canada_v2.sql...
python-opendrr_1         | 2021-04-28T02:05:41.099755956Z   - psql: Running Create_table_mh_thresholds.sql...
python-opendrr_1         | 2021-04-28T02:05:41.214256511Z   - psql: Running Create_MH_risk_building_ALL.sql...
python-opendrr_1         | 2021-04-28T02:05:41.508092905Z   - psql: Running Create_MH_risk_sauid_ALL.sql...
python-opendrr_1         | 2021-04-28T02:10:10.100270994Z   - psql: Running Create_all_tables_update.sql...
python-opendrr_1         | 2021-04-28T02:20:34.964928462Z   - psql: Running Create_site_exposure_to_building_and_sauid.sql...
python-opendrr_1         | 2021-04-28T02:35:00.021798633Z   - psql: Running Create_table_vs_30_BC_CAN_model_update_site_exposure.sql...
python-opendrr_1         | 2021-04-28T02:37:29.671171356Z  Generate Indicators
python-opendrr_1         | 2021-04-28T02:37:29.673844918Z   - psql: Running Create_physical_exposure_building_indicators_PhysicalExposure.sql...
python-opendrr_1         | 2021-04-28T02:37:29.952485192Z   - psql: Running Create_physical_exposure_sauid_indicators_view_PhysicalExposure.sql...
python-opendrr_1         | 2021-04-28T02:37:30.207160376Z   - psql: Running Create_physical_exposure_building_indicators_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-04-28T02:37:30.340670809Z   - psql: Running Create_physical_exposure_sauid_indicators_view_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-04-28T02:37:30.433239940Z   - psql: Running Create_physical_exposure_site_level_indicators_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-04-28T02:37:30.515304083Z   - psql: Running Create_risk_dynamics_indicators.sql...
python-opendrr_1         | 2021-04-28T02:37:30.710636570Z   - psql: Running Create_social_vulnerability_sauid_indicators_SocialFabric.sql...
python-opendrr_1         | 2021-04-28T02:37:30.784452472Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:38:01.922097582Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:38:04.548882843Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:38:11.804004458Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:38:26.251420856Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:38:52.320480892Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:39:05.867192688Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:39:09.161649333Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-28T02:41:04.063164951Z   - psql: Running Create_MH_risk_sauid_ALL.sql...
python-opendrr_1         | 2021-04-28T02:41:04.897841511Z Importing Raw PSRA Tables
python-opendrr_1         | 2021-04-28T03:23:23.123477146Z   - psql: Running psra_0.create_psra_schema.sql...
python-opendrr_1         | 2021-04-28T03:36:20.502834536Z   - psql: Running psra_6.Create_psra_merge_into_national_indicators.sql...
python-opendrr_1         | 2021-04-28T03:53:19.212588007Z  Importing scenario outputs into PostGIS...

with fsync=off, /var/lib/docker/volumes on NFS

foka@debian-e431:~/OpenDRR/opendrr-api/logs$ cat '2021-04-28 19:32:35-06:00.log' | egrep -v '(elasticsearch|pygeoapi)' | egrep '(Z  [A-Z]|Z Import|Z   -)'
python-opendrr_1         | 2021-04-28T23:12:43.675951018Z  Importing Census Boundaries
python-opendrr_1         | 2021-04-28T23:16:13.359467058Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-04-28T23:17:41.492909374Z  Importing Physical Exposure Model into PostGIS
python-opendrr_1         | 2021-04-28T23:19:40.277136426Z   - psql: Running Create_table_canada_exposure.sql...
python-opendrr_1         | 2021-04-28T23:22:49.073235211Z   - psql: Running Create_table_canada_site_exposure_ste.sql...
python-opendrr_1         | 2021-04-28T23:22:49.173419012Z  Importing VS30 Model into PostGIS...
python-opendrr_1         | 2021-04-28T23:24:38.514992392Z   - psql: Running Create_table_vs_30_CAN_site_model.sql...
python-opendrr_1         | 2021-04-28T23:24:38.602109569Z   - psql: Running Create_table_vs_30_CAN_site_model_xref.sql...
python-opendrr_1         | 2021-04-28T23:24:38.687074844Z  Importing Census Data
python-opendrr_1         | 2021-04-28T23:26:30.812048673Z   - psql: Running Create_table_2016_census_v3.sql...
python-opendrr_1         | 2021-04-28T23:26:30.920881172Z  Importing Sovi
python-opendrr_1         | 2021-04-28T23:43:02.766642606Z   - psql: Running Create_table_sovi_index_canada_v2.sql...
python-opendrr_1         | 2021-04-28T23:43:02.861195576Z   - psql: Running Create_table_sovi_census_canada.sql...
python-opendrr_1         | 2021-04-28T23:43:02.952922318Z   - psql: Running Create_table_sovi_thresholds.sql...
python-opendrr_1         | 2021-04-28T23:43:03.031158865Z  Importing LUTs
python-opendrr_1         | 2021-04-28T23:43:04.253111522Z   - psql: Running Create_collapse_probability_table.sql...
python-opendrr_1         | 2021-04-28T23:43:05.340567402Z   - psql: Running Create_retrofit_costs_table.sql...
python-opendrr_1         | 2021-04-28T23:43:05.438588166Z  Importing GHSL
python-opendrr_1         | 2021-04-28T23:43:54.943245461Z   - psql: Running Create_table_GHSL.sql...
python-opendrr_1         | 2021-04-28T23:43:55.067643430Z  Importing MH Intensity
python-opendrr_1         | 2021-04-28T23:44:16.809689508Z  Importing Hazard Threat Thresholds
python-opendrr_1         | 2021-04-28T23:44:17.774329701Z   - psql: Running Create_table_mh_intensity_canada_v2.sql...
python-opendrr_1         | 2021-04-28T23:44:17.874005633Z   - psql: Running Create_table_mh_thresholds.sql...
python-opendrr_1         | 2021-04-28T23:44:17.957890708Z   - psql: Running Create_MH_risk_building_ALL.sql...
python-opendrr_1         | 2021-04-28T23:44:18.236917828Z   - psql: Running Create_MH_risk_sauid_ALL.sql...
python-opendrr_1         | 2021-04-28T23:47:38.329901576Z   - psql: Running Create_all_tables_update.sql...
python-opendrr_1         | 2021-04-28T23:57:03.720497561Z   - psql: Running Create_site_exposure_to_building_and_sauid.sql...
python-opendrr_1         | 2021-04-29T00:05:31.248861214Z   - psql: Running Create_table_vs_30_BC_CAN_model_update_site_exposure.sql...
python-opendrr_1         | 2021-04-29T00:07:38.244997398Z  Generate Indicators
python-opendrr_1         | 2021-04-29T00:07:38.245050201Z   - psql: Running Create_physical_exposure_building_indicators_PhysicalExposure.sql...
python-opendrr_1         | 2021-04-29T00:07:38.728509794Z   - psql: Running Create_physical_exposure_sauid_indicators_view_PhysicalExposure.sql...
python-opendrr_1         | 2021-04-29T00:07:38.872530765Z   - psql: Running Create_physical_exposure_building_indicators_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-04-29T00:07:38.948655591Z   - psql: Running Create_physical_exposure_sauid_indicators_view_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-04-29T00:07:39.025789023Z   - psql: Running Create_physical_exposure_site_level_indicators_PhysicalExposure_ste.sql...
python-opendrr_1         | 2021-04-29T00:07:39.094595738Z   - psql: Running Create_risk_dynamics_indicators.sql...
python-opendrr_1         | 2021-04-29T00:07:39.198102717Z   - psql: Running Create_social_vulnerability_sauid_indicators_SocialFabric.sql...
python-opendrr_1         | 2021-04-29T00:07:39.266440364Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:06.990833294Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:09.754871505Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:15.026236647Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:27.464268397Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:45.294293566Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:56.316951416Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:08:59.255547487Z  AS "VHt_Score",
python-opendrr_1         | 2021-04-29T00:11:01.123000796Z   - psql: Running Create_MH_risk_sauid_ALL.sql...
python-opendrr_1         | 2021-04-29T00:11:01.647525505Z Importing Raw PSRA Tables
python-opendrr_1         | 2021-04-29T00:49:11.616635093Z   - psql: Running psra_0.create_psra_schema.sql...
python-opendrr_1         | 2021-04-29T01:01:32.181000124Z   - psql: Running psra_6.Create_psra_merge_into_national_indicators.sql...
python-opendrr_1         | 2021-04-29T01:16:41.834203523Z  Importing scenario outputs into PostGIS...

with fsync=off sychronous_commit full_page_writes=off; /var/lib/docker/volumes on NFS

foka@debian:~/OpenDRR/opendrr-api/logs$ cat '2021-04-29 04:21:50-06:00.log' | egrep -v '(elasticsearch|pygeoapi)' | egrep '(Z  [A-Z]|Z Import|Z   -)'
python-opendrr_1         | 2021-04-29T10:08:54.200455137Z  Importing Census Boundaries
python-opendrr_1         | 2021-04-29T10:12:14.799719809Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-04-29T10:13:23.772007594Z  Importing Physical Exposure Model into PostGIS
python-opendrr_1         | 2021-04-29T10:14:59.554666066Z   - psql: Running Create_table_canada_exposure.sql...
python-opendrr_1         | 2021-04-29T10:15:57.848475016Z   - psql: Running Create_table_canada_site_exposure_ste.sql...
python-opendrr_1         | 2021-04-29T10:15:58.078787134Z  Importing VS30 Model into PostGIS...
python-opendrr_1         | 2021-04-29T10:16:46.897982444Z   - psql: Running Create_table_vs_30_CAN_site_model.sql...
python-opendrr_1         | 2021-04-29T10:16:47.153156815Z   - psql: Running Create_table_vs_30_CAN_site_model_xref.sql...
python-opendrr_1         | 2021-04-29T10:16:47.309122341Z  Importing Census Data
python-opendrr_1         | 2021-04-29T10:17:51.197384503Z   - psql: Running Create_table_2016_census_v3.sql...
python-opendrr_1         | 2021-04-29T10:17:51.353377436Z  Importing Sovi

@jvanulde
Copy link
Contributor

So with fsync off it's 51 minutes faster?

@anthonyfok
Copy link
Member Author

Hi @jvanulde, thanks for looking into this...

...even though this PR as well as the "benchmarks" are at a very premature stage. I am using this space sort of as a "brain-dump" for convenience sake, even though the results aren't ready.

The tests that I have made thus far are actually very sloppy 😅, as in:

  • they are based on different code base over a month apart
  • the PostgreSQL database resides on different place. (on local ext4 on HDD vs NFS)
  • Curl calls hidden between the lines
  • Me multitasking on the same test machine (e.g. running Chrome with many tabs, some runs with the HDD swapping and thrashing, etc.)
  • Careless record keeping...
  • Incomplete runs...
  • Not sure if adding command: -c fsync=off -c synchronous_commit=off -c full_page_writes=off actually reaches the actual PostgreSQL server. There is a small chance that the postgresql and postgis docker images work differently.

I was expecting to see 10× difference in speed as some reported, but I am not seeing that, getting pretty confused by the sloppy logs. For example:

Before, without fsync=off (supposedly): 1m14s

python-opendrr_1         | 2021-04-28T01:42:10.983191153Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-04-28T01:43:24.787709256Z  Importing Physical Exposure Model into PostGIS

After, with fsync=off (supposedly): 1m28s

python-opendrr_1         | 2021-04-28T23:16:13.359467058Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-04-28T23:17:41.492909374Z  Importing Physical Exposure Model into PostGIS

After, with fsync=off synchronous_commit=off full_page_writes=off (supposedly): 1m9s

python-opendrr_1         | 2021-04-29T10:12:14.799719809Z   - psql: Running Update_boundaries_SAUID_table.sql...
python-opendrr_1         | 2021-04-29T10:13:23.772007594Z  Importing Physical Exposure Model into PostGIS

So, very inconclusive, i.e. junk benchmark results. Sorry!

I'd better double check to see this PR is doing anything by using a special benchmark script like the one at https://pythonspeed.com/articles/faster-db-tests/ ... Sorry again!

@anthonyfok
Copy link
Member Author

anthonyfok commented Apr 30, 2021

Good news: Setting -c synchronous_commit=off with command: in docker-compose.yml does work.

Using an adopted test https://pythonspeed.com/articles/faster-db-tests/ (see the test-pgsql-speed branch, running

docker-compose -f docker-compose-pgsql-speed-test.yml down -v && \
    docker-compose -f docker-compose-pgsql-speed-test.yml up --build

while modifying command:, the time required to to write 'hello!' 10000 times to the database is reduced from about 2m20s to merely 3s. That's with /var/lib/docker/volumes on an ext4 filesystem on an HDD on my ThinkPad.

Real-life benchmark with actual OpenDRR data will have to wait. 😅 <grin, duck, run>

@anthonyfok
Copy link
Member Author

anthonyfok commented Apr 30, 2021

New idea: Use add_data.sh to change the three settings (fsync=off, etc.) instead?

I realized just today that these settings (fsync, synchronous_commit and full_page_writes) can be modified on-the-fly with, say, ALTER SYSTEM, but it has a side-effect of generating a postgresql.auto.conf to the postgis container.

Maybe ALTER DATABASE db-opendrr would be a better way to modify them? I.e., instead of the command: line in docker-compose.yml, we could use ALTER DATABASE db-opendrr to turn all three settings off in the beginning of add_data.sh, and to turn them back on near the end of add_data.sh? TODO: Test if it actually works, and benchmark.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speed up database writes with synchronous_commit=off (and full_page_write=off and fsync=off?)
2 participants