LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2004, 09:50 PM   #1
kernelvn
Member
 
Registered: Aug 2004
Posts: 91

Rep: Reputation: 15
PostgreSQL , how to speedup ? ?


I've install PostgreSQL , but it seem to be slow with the default configuration . I read in the document and find out some interesting parameters :

Quote:
shared_buffers (integer) 3500
Sets the number of shared memory buffers used by the database server.

sort_mem (integer)
Specifies the amount of memory to be used by internal sort operations and hash tables before switching to temporary disk files . Note that for a complex query, several sort or hash operations might be running in parallel

vacuum_mem (integer)
Specifies the maximum amount of memory to be used by VACUUM to keep track of to-be-reclaimed rows. The value is specified in kilobytes, and defaults to 8192 kB. Larger settings may improve the speed of vacuuming large tables that have many deleted rows.

fsync (boolean) false
If this option is on, the PostgreSQL server will use the fsync() system call in several places to make sure that updates are physically written to disk . However, using fsync() results in a performance penalty: when a transaction is committed, PostgreSQL must wait for the operating system to flush the write-ahead log to disk. When fsync is disabled, the operating system is allowed to do its best in buffering, ordering, and delaying writes
But changing it with out any knowleage is not the right way . I need some tip for that , could you please help me ?
Other thing is how to test the perfomance of postgres ( the number of transaction per second ), I want to see how effect it was when I changed some parameter

Please help me
 
Old 09-22-2004, 10:33 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
How is it that you're getting the feeling of it being slow? You're running a query that seems to take longer than it should? Over how much data? How many people access the database? Are you using indexes? You need to know what is going slow before you can fix it For instance, changing the vacuum_mem only improves the maintenance of the database, not it's operation.

If a particular query is running slow, you can use EXPLAIN to show what's happening for that query.

As for benchmarking... that's harder depending on what's going on. For instance, if you're the only user of the database, it's going to spend most of its time waiting for you to do something, so transactions per second is not going to be a useful figure. You could write up a script for psql that performs 1000 inserts and use 'time' to see how long it takes. Also test 1000 queries, updates, and deletes for a better picture.
 
Old 09-22-2004, 10:53 PM   #3
kernelvn
Member
 
Registered: Aug 2004
Posts: 91

Original Poster
Rep: Reputation: 15
Quote:
Are you using indexes?
I think that is one of the main problem to improve speed . But I can not find out where to turn it on . In creatdb does not contain it .

Quote:
You need to know what is going slow before you can fix it
Yes , you're right , I just image in my mind because I have no experience . But I want my database system can do as much as transaction per second as posible . For the maximum of people log in , I think it not so importance ( 50 is too good ) .
Now for example I set 50 is the maximum of connection , and how to make the number of transation boot up . Can you give me something more ?
 
Old 09-22-2004, 11:43 PM   #4
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Indexes are specific to your data. For example, if you have a table called "customers", and you regularly do a query like
select * from customers where name like 'A%'
then your query would be sped up a lot by creating an index on the name field, which you would do via an SQL command like "CREATE INDEX custname ON customer (name)"

I understand you want maximum performance, but that can only be achieved on a per-system basis. You can tune other things separately, like your hard drive performance, and that will very likely improve postgres as a side effect, but to try and measure transactions per second makes almost no sense. Inserting a row into a 40 column table will take longer than inserting a row into a 2 column table, but they are both transactions. A query that retrieves data from fifteen different tables with lots of crazy joins is a single transaction too, but will probably take far longer than the two inserts. You need to set up your system and create tests for the activities that will apply to your system - there is no single 'golden configuration' that just makes Postgres a speed demon.

This url http://www.phpbuilder.com/columns/sm...21.php3?page=2 helps explain the shared memory settings you listed above. The fsync parameter improves speed at the possible expense of data integrity (if the system crashes or loses power, your database may be in an inconsistent state - whether this is important to you or not depends on how much your database is used and how important the data is).
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
speedup SUSE 10 bnjmn1989 SUSE / openSUSE 2 10-26-2005 03:51 PM
XMMS playback does funky speedup thing hcgernhardt Linux - Software 6 06-19-2004 08:04 AM
Why doesn't -O3 -march=pentium-mmx -ffast-math speedup my programs ? NOT_a_n00b Linux - Software 1 12-14-2003 08:50 AM
postgresql -odbc & postgresql-jdbc installation kjsubbu Linux - Software 0 06-19-2003 02:50 AM
How do I make speedup to work with kazaa? Qebex Linux - Software 2 09-25-2002 05:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration