Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Optimizing Postgresql insert

Posted on 2004-08-02
4
Medium Priority
?
1,069 Views
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?
0
Comment
Question by:fattinka
  • 4
4 Comments
 
LVL 22

Expert Comment

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

su - postgres
psql prod
\q
vacuumdb prod

have you any superfluous indexes on this table ?
0
 
LVL 22

Accepted Solution

by:
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.
0
 
LVL 22

Expert Comment

by:earth man2
ID: 11696559
Syntax is

REINDEX { DATABASE | TABLE | INDEX } name [ FORCE ]
0
 
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
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…
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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.

886 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