dbTalk Databases Forums  

how much ram do i give postgres?

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss how much ram do i give postgres? in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Bruno Wolff III
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 01:35 PM






On Wed, Oct 20, 2004 at 08:25:22 -0500,
Josh Close <narshe (AT) gmail (DOT) com> wrote:
Quote:
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?
You might not need to do the vacuum fulls that often. If the your hourly
vacuums have a high enough fsm setting, they should be keeping the database
from continually growing in size. At that point daily vacuum fulls are
overkill and if they are slowing stuff down you want to run quickly, you
should cut back on them.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #12  
Old   
Josh Close
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 01:38 PM






On Wed, 20 Oct 2004 13:35:43 -0500, Bruno Wolff III <bruno (AT) wolff (DOT) to> wrote:
Quote:
You might not need to do the vacuum fulls that often. If the your hourly
vacuums have a high enough fsm setting, they should be keeping the database
from continually growing in size. At that point daily vacuum fulls are
overkill and if they are slowing stuff down you want to run quickly, you
should cut back on them.
I have the vacuum_mem set at 32M right now. I haven't changed the fsm
settings at all though.

-Josh

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #13  
Old   
Gary Doades
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 01:59 PM



On 20 Oct 2004 at 13:34, Josh Close wrote:

Quote:
How long does 100,000 rows take to insert exactly?

I believe with the bulk inserts, 100k only takes a couple mins.

Hmm, that seems a bit slow. How big are the rows you are inserting? Have you checked
the cpu and IO usage during the inserts? You will need to do some kind of cpu/IO
monitoring to determine where the bottleneck is.

What hardware is this on? Sorry if you specified it earlier, I can't seem to find mention of
it.

Cheers,
Gary.


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #14  
Old   
Josh Close
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 02:09 PM



On Wed, 20 Oct 2004 19:59:38 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote:
Quote:
Hmm, that seems a bit slow. How big are the rows you are inserting? Have you checked
the cpu and IO usage during the inserts? You will need to do some kind of cpu/IO
monitoring to determine where the bottleneck is.
The bulk inserts don't take full cpu. Between 40% and 80%. On the
other hand, a select will take 99% cpu.

Quote:
What hardware is this on? Sorry if you specified it earlier, I can't seem to find mention of
it.
It's on a P4 HT with 1,128 megs ram.

-Josh

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #15  
Old   
Gary Doades
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 02:49 PM



On 20 Oct 2004 at 14:09, Josh Close wrote:

Quote:
On Wed, 20 Oct 2004 19:59:38 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote:
Hmm, that seems a bit slow. How big are the rows you are inserting? Have you checked
the cpu and IO usage during the inserts? You will need to do some kind of cpu/IO
monitoring to determine where the bottleneck is.

The bulk inserts don't take full cpu. Between 40% and 80%. On the
other hand, a select will take 99% cpu.
Is this the select(1) query? Please post an explain analyze for this and any other "slow"
queries.

I would expect the selects to take 99% cpu if all the data you were trying to select was
already in memory. Is this the case in general? I can do a "select count(1)" on a 500,000
row table in about 1 second on a Athlon 2800+ if all the data is cached. It takes about 25
seconds if it has to fetch it from disk.

I have just done a test by inserting (via COPY) of 149,000 rows in a table with 23
columns, mostly numeric, some int4, 4 timestamps. This took 28 seconds on my
Windows XP desktop, Athlon 2800+, 7200 rpm SATA disk, Postgres 8.0 beta 2. It used
around 20% to 40% cpu during the copy. The only index was the int4 primary key,
nothing else.

How does this compare?

Quote:
What hardware is this on? Sorry if you specified it earlier, I can't seem to find mention of
it.

It's on a P4 HT with 1,128 megs ram.
Disk system??

Regards,
Gary.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
  #16  
Old   
Josh Close
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 03:36 PM



On Wed, 20 Oct 2004 20:49:54 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote:
Quote:
Is this the select(1) query? Please post an explain analyze for this and any other "slow"
queries.
I think it took so long 'cause it wasn't cached. The second time I ran
it, it took less than a second. How you can tell if something is
cached? Is there a way to see what's in cache?

Quote:
I would expect the selects to take 99% cpu if all the data you were trying to select was
already in memory. Is this the case in general? I can do a "select count(1)" on a 500,000
row table in about 1 second on a Athlon 2800+ if all the data is cached. It takes about 25
seconds if it has to fetch it from disk.
I think that's what's going on here.

Quote:
I have just done a test by inserting (via COPY) of 149,000 rows in a table with 23
columns, mostly numeric, some int4, 4 timestamps. This took 28 seconds on my
Windows XP desktop, Athlon 2800+, 7200 rpm SATA disk, Postgres 8.0 beta 2. It used
around 20% to 40% cpu during the copy. The only index was the int4 primary key,
nothing else.
Well, there are a 3 text columns or so, and that's why the COPY takes
longer than yours. That hasn't been a big issue though. I copies fast
enough.

Quote:
How does this compare?

Disk system??
It's in ide raid 1 config I believe. So it's not too fast. It will
soon be on a scsi raid 5 array. That should help speed some things up
also.

Quote:
Regards,
Gary.
What about the postgresql.conf config settings. This is what I have and why.

shared_buffers = 21250

This is 174 megs, which is 15% of total ram. I read somewhere that it
should be between 12-15% of total ram.

sort_mem = 32768

This is default.

vacuum_mem = 32768

This is 32 megs. I put it that high because of something I read here
http://www.varlena.com/varlena/Gener...bits/perf.html

#max_fsm_pages = 20000

Default. I would think this could be upped more, but I don't know how much.

effective_cache_size = 105750

This is 846 megs ram which is 75% of total mem. I put it there 'cause
of a reply I got on the performance list.

I made all these changes today, and haven't had much of a chance to
speed test postgres since.

Any thoughs on these settings?

-Josh

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #17  
Old   
Gary Doades
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 05:43 PM



On 20 Oct 2004 at 15:36, Josh Close wrote:

Quote:
On Wed, 20 Oct 2004 20:49:54 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote:
Is this the select(1) query? Please post an explain analyze for this and any other "slow"
queries.

I think it took so long 'cause it wasn't cached. The second time I ran
it, it took less than a second. How you can tell if something is
cached? Is there a way to see what's in cache?
No. The OS caches the data as read from the disk. If you need the data to be in memory
for performance then you need to make sure you have enough available RAM to hold
your typical result sets if possible.

Quote:
What about the postgresql.conf config settings. This is what I have and why.

sort_mem = 32768

This is default.
This is not the default. The default is 1000. You are telling Postgres to use 32Megs for
*each* sort that is taking place. If you have several queries each performing large sorts
you can quickly eat up available RAM this way. If you will only have a small number of
concurrrent queries performing sorts then this may be OK. Don't forget, a single query
can perform more than one sort operation. If you have 10 large sorts happening at the
same time, you can eat up to 320 megs this way!

You will need to tell us the number of updates/deletes you are having. This will
determine the vacuum needs. If the bulk of the data is inserted you may only need to
analyze frequently, not vacuum.

In order to get more help you will need to supply the update/delete frequency and the
explain analyze output from your queries.

Regards,
Gary.


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #18  
Old   
Josh Close
 
Posts: n/a

Default Re: how much ram do i give postgres? - 10-20-2004 , 05:53 PM



On Wed, 20 Oct 2004 23:43:54 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote:
Quote:
You will need to tell us the number of updates/deletes you are having. This will
determine the vacuum needs. If the bulk of the data is inserted you may only need to
analyze frequently, not vacuum.

In order to get more help you will need to supply the update/delete frequency and the
explain analyze output from your queries.
I will have to gather this information for you.

-Josh

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.