Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 August PostgreSQL: How to increase the performance of Bulk Insertion (INSERT)

PostgreSQL: How to increase the performance of Bulk Insertion (INSERT)

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

This is one of the important post for all PostgreSQL Database Administrator who are dealing with Bulk Insertion in their PostgreSQL Server.

We should optimize Bulk Insertion operation because It is also utilizing more system resources.

Few steps to increase the performance of Bulk Insertion:

  • If It is only one time data load, remove all Index and create after INSERT. For regular Bulk Insertion, look into Index part and try to optimize it.
  • Take a backup of all the Triggers and drop all the Triggers.
  • Use COPY command instead of INSERT.
  • If you can not use COPY command because of of INSERT multiple value, you should not give more than 1000 multiple values in single INSERT. All INSERT multiple values stored in the memory area which may decrease the INSERT performance.
  • Disable other database logging process.
  • If BULK INSERTION is running with a single transaction, you should also disable all FOREIGN KEYs and later you can enable it.
  • Change synchronous_commit=off to reduce the cost of committing.
  • Change Checkpoint default configuration, Increase the checkpoint_segments value.
  • Increase the size of shared_buffers, effective_cache_size, work_mem.
  • Prepared all statements on server side.
  • Disable Auto-Vacuum on Table.
  • Disable Auto Database Backup process.
  • Increase the system resource (Memory, Disk, CPU), If it is required.
  • Use SSD type of Disk for faster storage.

Note: Whatever you changed for BULK INSERTION, please do not forget to rollback after completion of BULK INSERTION.

Aug 26, 2016Anvesh Patel
PostgreSQL: Optimized way to get first Record per each GROUP (using DISTINCT ON, LATERAL)PostgreSQL: Change or Move Default Data Directory in Windows
Comments: 3
  1. pooja
    May 21, 2017 at 6:46 am

    I applied all the points and got a very good performance anvesh, thank you very much.

  2. Dhananjayan
    March 23, 2018 at 8:19 am

    Good Blog!!!!! It’s very useful. Thanks anvesh…

    • Anvesh Patel
      Anvesh Patel
      March 23, 2018 at 9:32 am

      thanks šŸ™‚

Anvesh Patel
Anvesh Patel

Database Engineer

August 26, 2016 PostgreSQLAnvesh Patel, checkpoint_segment, database, database research and development, dbrnd, index, insert, optimized insertion, plpgsql, Postgres Query, postgresql, PostgreSQL Administrator, PostgreSQL Error, PostgreSQL Programming, PostgreSQL Tips and Tricks, shared_buffers, trigger, work_mem
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
Ā© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....