pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Import Database
11+ messages / 7 participants
[nested] [flat]

* Import Database
@ 2001-01-29 18:14  Matt <matthewf9@aol.com (nospam)>
  0 siblings, 1 reply; 11+ messages in thread

From: Matt @ 2001-01-29 18:14 UTC (permalink / raw)
  To: pgsql-general

Hi there,

I am trying to find if importing a very large delimited text file is faster
with postgresql or mysql (with mysqlimport). Each night the transaction
system we use completes a text file of the days activities, which must be
loaded into a database, the speed is very important, mysqlimport takes less
than an hour, however sometimes crashes. Is postgresql likely to be faster
or slower at importing such vast amounts of data?

Matt







^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Import Database
@ 2001-02-05 20:22  Brett W. McCoy <bmccoy@chapelperilous.net>
  parent: Matt <matthewf9@aol.com (nospam)>
  0 siblings, 0 replies; 11+ messages in thread

From: Brett W. McCoy @ 2001-02-05 20:22 UTC (permalink / raw)
  To: Matt <matthewf9@aol.com>; +Cc: pgsql-general

On Mon, 29 Jan 2001, Matt wrote:

> I am trying to find if importing a very large delimited text file is faster
> with postgresql or mysql (with mysqlimport). Each night the transaction
> system we use completes a text file of the days activities, which must be
> loaded into a database, the speed is very important, mysqlimport takes less
> than an hour, however sometimes crashes. Is postgresql likely to be faster
> or slower at importing such vast amounts of data?

How much data are you talking about?  Megabytes?  Gigabytes?

PostgreSQL will load fairly fast if you turn off fsync and delete your
indexes and rebuild them after the import.  I haven't played with large
imports on the newer Postgres, but a couple of years ago I was importing
millions of rows into 6.5 on a lowly Pentium 200, with no indexes and with
fsync turned off.  I had to load each table separately (each one was
several million rows, plain old delimited delimited text), and they loaded
fairly quickly -- maybe 10 or 15 minutes, just using the COPY command
inside of psql.  With fsync on and indexes in place, it took *hours* to
load and basically slowed the server to a crawl because of the I/O
overhead.

-- Brett





^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Import Database
@ 2019-05-05 16:47  Sathish Kumar <satcse88@gmail.com>
  0 siblings, 2 replies; 11+ messages in thread

From: Sathish Kumar @ 2019-05-05 16:47 UTC (permalink / raw)
  To: pgsql-general

Hi,

I am trying to import a database of size 300+gb to another server. It's
taking a long time.

4vCPU
15GB RAM

psql -h newserver -U dbuser -d production -W < prod.sql



Is there a way to speed up the importing process by tweaking Postgresql
config like maintenance_workmem, work_mem, shared_buffers etc.,

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Import Database
@ 2019-05-05 16:56  Ravi Krishna <ravi_krishna@aol.com>
  parent: Sathish Kumar <satcse88@gmail.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Ravi Krishna @ 2019-05-05 16:56 UTC (permalink / raw)
  To: Sathish Kumar <satcse88@gmail.com>; +Cc: pgsql-general

IMO you are using the slowest tool to import.

Just one quick question: Why can't you take cluster backup using any of the tools available and then drop all 
unwanted databases after you import the cluster.

pg_basebackup will do a good job.




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Import Database
@ 2019-05-05 17:20  Andreas Kretschmer <andreas@a-kretschmer.de>
  parent: Sathish Kumar <satcse88@gmail.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Andreas Kretschmer @ 2019-05-05 17:20 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org



Am 05.05.19 um 18:47 schrieb Sathish Kumar:
> Is there a way to speed up the importing process by tweaking 
> Postgresql config like maintenance_workmem, work_mem, shared_buffers etc.,

sure, take the dump in custom-format and use pg_restore with -j 
<number_of_jobs>. You can increase maintenance_work_mem maybe to 4GB to 
speedup index creation.


Andreas

-- 
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com






^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Import Database
@ 2019-05-05 17:26  Ron <ronljohnsonjr@gmail.com>
  parent: Andreas Kretschmer <andreas@a-kretschmer.de>
  0 siblings, 1 reply; 11+ messages in thread

From: Ron @ 2019-05-05 17:26 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 5/5/19 12:20 PM, Andreas Kretschmer wrote:
>
>
> Am 05.05.19 um 18:47 schrieb Sathish Kumar:
>> Is there a way to speed up the importing process by tweaking Postgresql 
>> config like maintenance_workmem, work_mem, shared_buffers etc.,
>
> sure, take the dump in custom-format and use pg_restore with -j 
> <number_of_jobs>.

Custom format or directory format?

-- 
Angular momentum makes the world go 'round.





^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [External] Re: Import Database
@ 2019-05-05 17:32  Vijaykumar Jain <vjain@opentable.com>
  parent: Ravi Krishna <ravi_krishna@aol.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Vijaykumar Jain @ 2019-05-05 17:32 UTC (permalink / raw)
  To: Ravi Krishna <ravi_krishna@aol.com>; +Cc: Sathish Kumar <satcse88@gmail.com>; pgsql-general

Yes.
I do bump up maintenance_work_mem temporarily during a restore.
it helps in rebuilding on indexes a little faster.
Turning fsync off during restore will help the restore a little fast too
but in case of any crash you may have to restart the restore from scratch.
Also do have the option to take pg_dump and run pg_restore ? or you just
the have the raw sql dump to work with?
if you have the option of taking a dump again, you can try using pg_dump
and pg_restore with -Fc (custom format) and -j n (parallel)  option along
with temp bump in maint memory.
This will make the restore a little faster that raw sql dump I think.
If you are on pg10 or above? you can use logical replication to mirror  the
database.
There are blogs by several people explaining how to do that, that may be
helpful.


On Sun, 5 May 2019 at 10:29 PM Ravi Krishna <ravi_krishna@aol.com> wrote:

> IMO you are using the slowest tool to import.
>
> Just one quick question: Why can't you take cluster backup using any of
> the tools available and then drop all
> unwanted databases after you import the cluster.
>
> pg_basebackup will do a good job.
>
> --

Regards,
Vijay

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [External] Re: Import Database
@ 2019-05-05 23:14  Sathish Kumar <satcse88@gmail.com>
  parent: Vijaykumar Jain <vjain@opentable.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Sathish Kumar @ 2019-05-05 23:14 UTC (permalink / raw)
  To: Vijaykumar Jain <vjain@opentable.com>; +Cc: Ravi Krishna <ravi_krishna@aol.com>; pgsql-general

Hi,

I am trying to export our database in GCE instance to Google Cloud SQL.

Below are the commands used to export/import the database. I am exporting
only 1 database which is required.

Export:

pg_dump -h olddbserver -U dbuser --format=plain --no-owner --no-acl
production     | sed -E 's/(DROP|CREATE|COMMENT ON) EXTENSION/-- \1
EXTENSION/g' > prod.sql


Import:

psql -h newcloudsqldbserver -U dbuser -d production -W < prod.sql


On Mon, May 6, 2019, 1:32 AM Vijaykumar Jain <vjain@opentable.com> wrote:

> Yes.
> I do bump up maintenance_work_mem temporarily during a restore.
> it helps in rebuilding on indexes a little faster.
> Turning fsync off during restore will help the restore a little fast too
> but in case of any crash you may have to restart the restore from scratch.
> Also do have the option to take pg_dump and run pg_restore ? or you just
> the have the raw sql dump to work with?
> if you have the option of taking a dump again, you can try using pg_dump
> and pg_restore with -Fc (custom format) and -j n (parallel)  option along
> with temp bump in maint memory.
> This will make the restore a little faster that raw sql dump I think.
> If you are on pg10 or above? you can use logical replication to mirror
>  the database.
> There are blogs by several people explaining how to do that, that may be
> helpful.
>
>
> On Sun, 5 May 2019 at 10:29 PM Ravi Krishna <ravi_krishna@aol.com> wrote:
>
>> IMO you are using the slowest tool to import.
>>
>> Just one quick question: Why can't you take cluster backup using any of
>> the tools available and then drop all
>> unwanted databases after you import the cluster.
>>
>> pg_basebackup will do a good job.
>>
>> --
>
> Regards,
> Vijay
>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [External] Re: Import Database
@ 2019-05-05 23:17  Sathish Kumar <satcse88@gmail.com>
  parent: Sathish Kumar <satcse88@gmail.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Sathish Kumar @ 2019-05-05 23:17 UTC (permalink / raw)
  To: Vijaykumar Jain <vjain@opentable.com>; +Cc: Ravi Krishna <ravi_krishna@aol.com>; pgsql-general

Hi All,

Postgresql version: 9.6

On Mon, May 6, 2019, 7:14 AM Sathish Kumar <satcse88@gmail.com> wrote:

> Hi,
>
> I am trying to export our database in GCE instance to Google Cloud SQL.
>
> Below are the commands used to export/import the database. I am exporting
> only 1 database which is required.
>
> Export:
>
> pg_dump -h olddbserver -U dbuser --format=plain --no-owner --no-acl production     | sed -E 's/(DROP|CREATE|COMMENT ON) EXTENSION/-- \1 EXTENSION/g' > prod.sql
>
>
> Import:
>
> psql -h newcloudsqldbserver -U dbuser -d production -W < prod.sql
>
>
> On Mon, May 6, 2019, 1:32 AM Vijaykumar Jain <vjain@opentable.com> wrote:
>
>> Yes.
>> I do bump up maintenance_work_mem temporarily during a restore.
>> it helps in rebuilding on indexes a little faster.
>> Turning fsync off during restore will help the restore a little fast too
>> but in case of any crash you may have to restart the restore from scratch.
>> Also do have the option to take pg_dump and run pg_restore ? or you just
>> the have the raw sql dump to work with?
>> if you have the option of taking a dump again, you can try using pg_dump
>> and pg_restore with -Fc (custom format) and -j n (parallel)  option along
>> with temp bump in maint memory.
>> This will make the restore a little faster that raw sql dump I think.
>> If you are on pg10 or above? you can use logical replication to mirror
>>  the database.
>> There are blogs by several people explaining how to do that, that may be
>> helpful.
>>
>>
>> On Sun, 5 May 2019 at 10:29 PM Ravi Krishna <ravi_krishna@aol.com> wrote:
>>
>>> IMO you are using the slowest tool to import.
>>>
>>> Just one quick question: Why can't you take cluster backup using any of
>>> the tools available and then drop all
>>> unwanted databases after you import the cluster.
>>>
>>> pg_basebackup will do a good job.
>>>
>>> --
>>
>> Regards,
>> Vijay
>>
>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Import Database
@ 2019-05-06 10:35  Andreas Kretschmer <andreas@a-kretschmer.de>
  parent: Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Andreas Kretschmer @ 2019-05-06 10:35 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org



Am 05.05.19 um 19:26 schrieb Ron:
> On 5/5/19 12:20 PM, Andreas Kretschmer wrote:
>>
>>
>> Am 05.05.19 um 18:47 schrieb Sathish Kumar:
>>> Is there a way to speed up the importing process by tweaking 
>>> Postgresql config like maintenance_workmem, work_mem, shared_buffers 
>>> etc.,
>>
>> sure, take the dump in custom-format and use pg_restore with -j 
>> <number_of_jobs>.
>
> Custom format or directory format?

both are possible for that.

Regards, Andreas

-- 
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com






^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Import Database
@ 2019-05-07 01:22  Sathish Kumar <satcse88@gmail.com>
  parent: Andreas Kretschmer <andreas@a-kretschmer.de>
  0 siblings, 0 replies; 11+ messages in thread

From: Sathish Kumar @ 2019-05-07 01:22 UTC (permalink / raw)
  To: Andreas Kretschmer <andreas@a-kretschmer.de>; +Cc: pgsql-general@lists.postgresql.org

Hi All,

Is there any other option to restore faster using psql, since I have to
export it as plain text dump.

--format=plain

Only plain SQL format is supported by Cloud SQL.


I cannot use pgrestore option for plain text sql dump restore.

On Mon, May 6, 2019, 6:35 PM Andreas Kretschmer <andreas@a-kretschmer.de>
wrote:

>
>
> Am 05.05.19 um 19:26 schrieb Ron:
> > On 5/5/19 12:20 PM, Andreas Kretschmer wrote:
> >>
> >>
> >> Am 05.05.19 um 18:47 schrieb Sathish Kumar:
> >>> Is there a way to speed up the importing process by tweaking
> >>> Postgresql config like maintenance_workmem, work_mem, shared_buffers
> >>> etc.,
> >>
> >> sure, take the dump in custom-format and use pg_restore with -j
> >> <number_of_jobs>.
> >
> > Custom format or directory format?
>
> both are possible for that.
>
> Regards, Andreas
>
> --
> 2ndQuadrant - The PostgreSQL Support Company.
> www.2ndQuadrant.com
>
>
>
>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2019-05-07 01:22 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-29 18:14 Import Database Matt <matthewf9@aol.com (nospam)>
2001-02-05 20:22 ` Brett W. McCoy <bmccoy@chapelperilous.net>
2019-05-05 16:47 Import Database Sathish Kumar <satcse88@gmail.com>
2019-05-05 16:56 ` Ravi Krishna <ravi_krishna@aol.com>
2019-05-05 17:32   ` Vijaykumar Jain <vjain@opentable.com>
2019-05-05 23:14     ` Sathish Kumar <satcse88@gmail.com>
2019-05-05 23:17       ` Sathish Kumar <satcse88@gmail.com>
2019-05-05 17:20 ` Andreas Kretschmer <andreas@a-kretschmer.de>
2019-05-05 17:26   ` Ron <ronljohnsonjr@gmail.com>
2019-05-06 10:35     ` Andreas Kretschmer <andreas@a-kretschmer.de>
2019-05-07 01:22       ` Sathish Kumar <satcse88@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox