Link to home
Start Free TrialLog in
Avatar of fattinka
fattinka

asked on

Optimizing Postgresql insert

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?
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you vacuumed your database recently?
eg

su - postgres
psql prod
\q
vacuumdb prod

have you any superfluous indexes on this table ?
ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Syntax is

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