diff --git a/scripts/partition_vehicle_parts.py b/scripts/partition_vehicle_parts.py index 539dbb1..9727373 100644 --- a/scripts/partition_vehicle_parts.py +++ b/scripts/partition_vehicle_parts.py @@ -30,7 +30,7 @@ from datetime import datetime import psycopg2 DSN = os.environ.get('MASTER_DB_URL', 'postgresql://postgres@/nexus_autoparts') -BATCH_SIZE = 500_000 +BATCH_SIZE = 10_000_000 PARTITIONS = 16 @@ -124,8 +124,7 @@ def create_indexes(cur): CREATE INDEX idx_vp_new_mye ON vehicle_parts_new(model_year_engine_id); """) cur.execute(""" - ALTER TABLE vehicle_parts_new ADD CONSTRAINT uq_vp_new_mye_part - UNIQUE (model_year_engine_id, part_id); + CREATE INDEX idx_vp_new_mye_part ON vehicle_parts_new(model_year_engine_id, part_id); """) log("Indexes created.") @@ -167,6 +166,8 @@ def main(): conn = get_conn() conn.autocommit = False cur = conn.cursor() + cur.execute("SET synchronous_commit = off;") + cur.execute("SET work_mem = '256MB';") try: # Check prerequisites