Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Optimizing Postgresql insert

Posted on 2004-08-02
Medium Priority
Last Modified: 2012-08-13
I am currently using postgresql 7.3.4 with a postfix/amavis/spamassassin mail filter. I've had a lot of performance problems..right now, the whole thing seems to be running fine, except when it comes to INSERT queries. It takes pgsql aproximatively 25 seconds to insert ONE row!! The query itself is "INSERT INTO table (field1,field2,field3) VALUES (?,?,?), and that particular table contains 1,628,525 rows. Does anyone have a clue on how i can optimize this?
Question by:fattinka
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 22

Expert Comment

by:earth man2
ID: 11696160
Have you vacuumed your database recently?

su - postgres
psql prod
vacuumdb prod

have you any superfluous indexes on this table ?
LVL 22

Accepted Solution

earth man2 earned 1350 total points
ID: 11696228
Try REINDEXing your indexes.

REINDEX index_name;

See POSTGRES_HOME/contrib/reindexdb for a utility that will reindex all your database indexes.
LVL 22

Expert Comment

by:earth man2
ID: 11696559
Syntax is

LVL 22

Expert Comment

by:earth man2
ID: 11698516
If your database must remain live then dropping and recreating the indexes may be better option than using REINDEX command.  REINDEX command creates a table lock, see  documentation.

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question