mirror of
https://github.com/dimitri/pgloader.git
synced 2026-03-16 09:31:33 +01:00
By default, pgloader will start as many parallel CREATE INDEX commands as the maximum number of indexes you have on any single table that takes part in the load. As this number might be so great as to exhaust the target PostgreSQL server (e.g. maintenance_work_mem), we add an option to limit that to something reasonnable when the source schema isn't. Fix #386 in which 150 indexes are found on a single source table.
40 lines
1.2 KiB
Fish
40 lines
1.2 KiB
Fish
load database
|
|
from mysql://root@localhost/sakila
|
|
into postgresql:///sakila
|
|
|
|
-- WITH include drop, create tables, no truncate,
|
|
-- create indexes, reset sequences, foreign keys
|
|
|
|
-- WITH batch rows = 10000
|
|
|
|
WITH concurrency = 1, workers = 6,
|
|
max parallel create index = 4
|
|
|
|
SET maintenance_work_mem to '128MB',
|
|
work_mem to '12MB',
|
|
search_path to 'sakila, public, "$user"'
|
|
|
|
CAST type date drop not null drop default using zero-dates-to-null,
|
|
type datetime to timestamp drop default drop not null using zero-dates-to-null
|
|
|
|
-- type tinyint to boolean using tinyint-to-boolean,
|
|
-- type year to integer drop typemod -- now a default
|
|
|
|
-- MATERIALIZE VIEWS film_list, staff_list
|
|
MATERIALIZE ALL VIEWS
|
|
|
|
ALTER TABLE NAMES MATCHING ~/_list$/, 'sales_by_store', ~/sales_by/
|
|
SET SCHEMA 'mv'
|
|
|
|
ALTER TABLE NAMES MATCHING 'sales_by_store' RENAME TO 'sales_by_store_list'
|
|
ALTER TABLE NAMES MATCHING 'film' RENAME TO 'films'
|
|
|
|
-- INCLUDING ONLY TABLE NAMES MATCHING ~/film/, 'actor'
|
|
-- EXCLUDING TABLE NAMES MATCHING ~<ory>
|
|
|
|
BEFORE LOAD DO
|
|
$$ create schema if not exists sakila; $$,
|
|
$$ create schema if not exists mv; $$,
|
|
$$ alter database sakila set search_path to sakila, mv, public; $$;
|
|
|