![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I know this is kinda a debate, but how much ram do I give postgres? I've seen many places say around 10-15% or some say 25%....... If all this server is doing is running postgres, why can't I give it 75%+? Should the limit be as much as possible as long as the server doesn't use any swap? |
#3
| |||
| |||
|
|
The short answer is no; the sweet spot for shared_buffers is usually on the order of 10000 buffers, and trying to go for "75% of RAM" isn't going to do anything except hurt. For the long answer see the pgsql-performance list archives. regards, tom lane |

#4
| |||
| |||
|
|
Well, I didn't find a whole lot in the list-archives, so I emailed that list whith a few more questions. My postgres server is just crawling right now ![]() |
#5
| |||
| |||
|
|
Unlike many other database engines the shared buffers of Postgres is not a private cache of the database data. It is a working area shared between all the backend processes. This needs to be tuned for number of connections and overall workload, *not* the amount of your database that you want to keep in memory. There is still lots of debate about what the "sweet spot" is. Maybe there isn't one, but its not normally 75% of RAM. If anything, the effective_cache_size needs to be 75% of (available) RAM as this is telling Postgres the amount of your database the *OS* is likely to cache in memory. Having said that, I think you will need to define "crawling". Is it updates/inserts that are slow? This may be triggers/rules/referential integrity checking etc that is slowing it. If it is selects that are slow, this may be incorrect indexes or sub-optimal queries. You need to show us what you are trying to do and what the results are. |
#6
| |||
| |||
|
|
It's slow due to several things happening all at once. There are a lot of inserts and updates happening. There is periodically a bulk insert of 500k - 1 mill rows happening. I'm doing a vacuum anaylyze every hour due to the amount of transactions happening, and a vacuum full every night. All this has caused selects to be very slow. At times, a "select count(1)" from a table will take several mins. I don't think selects would have to wait on locks by inserts/updates would it? I would just like to do anything possible to help speed this up. If there are really many rows in table , select count(1) would be a |
#7
| |||
| |||
|
|
It's slow due to several things happening all at once. There are a lot of inserts and updates happening. There is periodically a bulk insert of 500k - 1 mill rows happening. I'm doing a vacuum anaylyze every hour due to the amount of transactions happening, and a vacuum full every night. All this has caused selects to be very slow. At times, a "select count(1)" from a table will take several mins. I don't think selects would have to wait on locks by inserts/updates would it? |
#8
| ||||
| ||||
|
|
1: Is the bulk insert being done inside of a single transaction, or as individual inserts? |
|
2: Are your fsm settings high enough for an hourly vacuum to be effective? |
|
3: How selective is the where clause for your select (1) query? If there is no where clause or the where clause isn't very selective, then there will be a sequential scan every time. Since PostgreSQL has to hit the table after using an index anyway, if it's going to retrieve a fair percent of a table, it just goes right to a seq scan, which for postgresql, is the right thing to do. |
|
Post "explain analyze" of your slowest queries to the performance list if you can. |
#9
| |||
| |||
|
|
On Wed, 20 Oct 2004 09:52:25 -0600, Scott Marlowe <smarlowe (AT) qwest (DOT) net> wrote: 1: Is the bulk insert being done inside of a single transaction, or as individual inserts? The bulk insert is being done by COPY FROM STDIN. It copies in 100,000 rows at a time, then disconnects, reconnects, and copies 100k more, and repeats 'till done. There are no indexes on the tables that the copy is being done into either, so it won't be slowed down by that at all. |
#10
| ||||
| ||||
|
|
What about triggers? Also constraints (check contraints, integrity constraints) All these will slow the inserts/updates down. |
|
If you have integrity constraints make sure you have indexes on the referenced columns in the referenced tables and make sure the data types are the same. How long does 100,000 rows take to insert exactly? |
|
How many updates are you performing each hour? |
|
Regards, Gary. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster |
![]() |
| Thread Tools | |
| Display Modes | |
| |