Unix Technical Forum

postgres slowdown question

This is a discussion on postgres slowdown question within the Pgsql Performance forums, part of the PostgreSQL category; --> Dear Postgres Masters: We are using postgres 7.4 in our java application on RedHat linux. The Java application connects ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 11:35 AM
Shachindra Agarwal
 
Posts: n/a
Default postgres slowdown question

Dear Postgres Masters:



We are using postgres 7.4 in our java application on RedHat linux. The
Java application connects to Postgres via JDBC. The application goes
through a 'discovery' phase, whereas it adds large amount of data into
postgres. Typically, we are adding about a million records in various
tables. The application also issues multiple queries to the database at
the same time. We do not delete any records during the discovery phase.
Both the java application and the postgres are installed on the same
machine.



At the beginning, the application is able to add in the order of 100
record per minute. Gradually (after several hours), it slows down to
less than 10 records per minute. At this time, postgres processes take
between 80-99% of CPU. When we reindex the database, the speed bumps up
to about 30 records per minute. Now, postgres server takes between
50-70% CPU.



We have the following in the postgresql.conf :



max_fsm_pages = 500000

fsync = false



We certainly can not live with this kind of performance. I believe
postgres should be able to handle much larger datasets but I can not
point my finger as to what are we doing wrong. Can somebody please point
me to the right direction.



With kind regards,



-- Shachindra Agarwal.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 11:35 AM
John A Meinel
 
Posts: n/a
Default Re: postgres slowdown question

Shachindra Agarwal wrote:

> Dear Postgres Masters:
>
> We are using postgres 7.4 in our java application on RedHat linux. The
> Java application connects to Postgres via JDBC. The application goes
> through a ‘discovery’ phase, whereas it adds large amount of data into
> postgres. Typically, we are adding about a million records in various
> tables. The application also issues multiple queries to the database
> at the same time. We do not delete any records during the discovery
> phase. Both the java application and the postgres are installed on the
> same machine.
>
> At the beginning, the application is able to add in the order of 100
> record per minute. Gradually (after several hours), it slows down to
> less than 10 records per minute. At this time, postgres processes take
> between 80-99% of CPU. When we reindex the database, the speed bumps
> up to about 30 records per minute. Now, postgres server takes between
> 50-70% CPU.
>
> We have the following in the postgresql.conf :
>
> max_fsm_pages = 500000
>
> fsync = false
>
> We certainly can not live with this kind of performance. I believe
> postgres should be able to handle much larger datasets but I can not
> point my finger as to what are we doing wrong. Can somebody please
> point me to the right direction.
>
> With kind regards,
>
> -- Shachindra Agarwal.
>

A few questions first. How are you loading the data? Are you using
INSERT or COPY? Are you using a transaction, or are you autocommitting
each row?

You really need a transaction, and preferably use COPY. Both can help
performance a lot. (In some of the tests, single row inserts can be
10-100x slower than doing it in bulk.)

Also, it sounds like you have a foreign key issue. That as things fill
up, the foreign key reference checks are slowing you down.
Are you using ANALYZE as you go? A lot of times when you only have <1000
rows a sequential scan is faster than using an index, and if you don't
inform postgres that you have more rows, it might still use the old seqscan.

There are other possibilities, but it would be nice to know about your
table layout, and possibly an EXPLAIN ANALYZE of the inserts that are
going slow.

John
=:->

PS> I don't know if JDBC supports COPY, but it certainly should support
transactions.



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCZsAQJdeBCYSNAAMRAgc1AKDK15PKcX7QO8h+fvU1yB/+RyNIcQCfSYFe
o4DSG/sdnr2PssCEatyw16o=
=TkCR
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com