From: | "James Pang (chaolpan)" <chaolpan(at)cisco(dot)com> |
---|---|
To: | Jim Mlodgenski <jimmy76(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org> |
Subject: | RE: alter table xxx set unlogged take long time |
Date: | 2022-07-26 12:59:15 |
Message-ID: | PH0PR11MB51918C3648CF7FECAC90CABED6949@PH0PR11MB5191.namprd11.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
We use JDBC to export data into csv ,then copy that to Postgres. Multiple sessions working on multiple tables. If not set unlogged , how to make COPY run fast ? possible to start a transaction include all of these “truncate table xxx; copy table xxxx; create index on tables….” With wal_level=minimal, is it ok to make copy and create index without logging ?
James
From: Jim Mlodgenski <jimmy76(at)gmail(dot)com>
Sent: Tuesday, July 26, 2022 8:53 PM
To: James Pang (chaolpan) <chaolpan(at)cisco(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>; pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: alter table xxx set unlogged take long time
On Tue, Jul 26, 2022 at 8:45 AM James Pang (chaolpan) <chaolpan(at)cisco(dot)com<mailto:chaolpan(at)cisco(dot)com>> wrote:
Without step 3 , copy data take long time. Use wal_level=minimal can help make COPY load data without logging ?
I assume that you're most concerned with the total time of moving the data from the source database into the final table so you might get a big win by not moving the data twice and directly load the table through a Foregin Data Wrapper and avoid the csv export/import. Something like the oracle_fdw might help here:
https://github.com/laurenz/oracle_fdw
-----Original Message-----
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us<mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>>
Sent: Tuesday, July 26, 2022 8:43 PM
To: James Pang (chaolpan) <chaolpan(at)cisco(dot)com<mailto:chaolpan(at)cisco(dot)com>>
Cc: Jim Mlodgenski <jimmy76(at)gmail(dot)com<mailto:jimmy76(at)gmail(dot)com>>; pgsql-performance(at)lists(dot)postgresql(dot)org<mailto:pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: alter table xxx set unlogged take long time
"James Pang (chaolpan)" <chaolpan(at)cisco(dot)com<mailto:chaolpan(at)cisco(dot)com>> writes:
> How to make it fast ? These are our steps about copy large data from Oracle to Postgres
> 1. Create table in Postgres 2. Extract data from Oracle to CSV 3. Alter table set xxx unlogged, 4. Run copy command into Postgres db 5. Alter table set xxx logged 6. Create index …
The easy answer is to skip steps 3 and 5.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2022-07-26 15:03:33 | Re: alter table xxx set unlogged take long time |
Previous Message | Jim Mlodgenski | 2022-07-26 12:52:59 | Re: alter table xxx set unlogged take long time |