pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedperformance issues
12+ messages / 9 participants
[nested] [flat]
* performance issues
@ 2001-06-13 13:32 DHSC Webmaster <webmaster@dhs-club.com>
2001-06-13 14:29 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: DHSC Webmaster @ 2001-06-13 13:32 UTC (permalink / raw)
To: pgsql-admin
Hello all,
We are running 7.0.3 on a RH 7.0 box w/twin 733 pentium CPUs, 512 meg.
ram and a 3 drive raid 5 scsi array. The machine is dedicated. Our main
table is about 700,000 rows with an associated table of about 15,000
rows.
-N 128 -B 256
logging to a file
Without spelling out our complete schema I'll give some basic info
main table has 37 columns with 3 indexes, several foreign key
constraints and one rule
the associated table has about 10 columns all or which are int 4 with
the exception of one text
Most of our queries are simple select queries, half of which would use
the indexes.
Now, does this scenario sound about right or do I have a lot of work to
do?
At any given moment having 12 - 16 queries running (say 1 update & one
insert, the rest selects),
I'm dragging bad. Vacuum -z was just run. top gives me numbers around
20. Even with just a 2 or 3 queries running top gives me 2 - 3. Does
this sound typical?
If my information is insufficient to give a ballpark quess, perhaps you
could give me some normal types of performance figures.
Thank you for your feedback.
--
Bill MacArthur
Webmaster
DHS Club
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: performance issues
2001-06-13 13:32 performance issues DHSC Webmaster <webmaster@dhs-club.com>
@ 2001-06-13 14:29 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 14:49 ` Re: performance issues DHSC Webmaster <webmaster@dhs-club.com>
0 siblings, 1 reply; 12+ messages in thread
From: Tom Lane @ 2001-06-13 14:29 UTC (permalink / raw)
To: DHSC Webmaster <webmaster@dhs-club.com>; +Cc: pgsql-admin
DHSC Webmaster <webmaster@dhs-club.com> writes:
> We are running 7.0.3 on a RH 7.0 box w/twin 733 pentium CPUs, 512 meg.
> ram and a 3 drive raid 5 scsi array. The machine is dedicated. Our main
> table is about 700,000 rows with an associated table of about 15,000
> rows.
> -N 128 -B 256
That's not nearly enough buffers for an installation that size. Try -B
of a few thousand.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: performance issues
2001-06-13 13:32 performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-13 14:29 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-06-14 14:49 ` DHSC Webmaster <webmaster@dhs-club.com>
2001-06-14 15:51 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: DHSC Webmaster @ 2001-06-14 14:49 UTC (permalink / raw)
To: pgsql-admin
Thank you Tom. That has seemed to help substantially.
I received another sugestion to increase -B 30000 which would give 240
meg. to postgres. I plan to give that a try. I've already reset the
SHMMAX val in sysctl to accomodate that size. Do you see any reason not
to try this? My thought is if some is good, more must be better. :)
Also I noticed in this artice:
http://www.ca.postgresql.org/docs/faq-english.html#3.7
mention of another memory parameter (-S), however the elephant book
refers to -S as silent mode.
Could you clarify this?
Tom Lane wrote:
>
> DHSC Webmaster <webmaster@dhs-club.com> writes:
> > We are running 7.0.3 on a RH 7.0 box w/twin 733 pentium CPUs, 512 meg.
> > ram and a 3 drive raid 5 scsi array. The machine is dedicated. Our main
> > table is about 700,000 rows with an associated table of about 15,000
> > rows.
> > -N 128 -B 256
>
> That's not nearly enough buffers for an installation that size. Try -B
> of a few thousand.
>
> regards, tom lane
--
Bill MacArthur
Webmaster
DHS Club
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: performance issues
2001-06-13 13:32 performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-13 14:29 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 14:49 ` Re: performance issues DHSC Webmaster <webmaster@dhs-club.com>
@ 2001-06-14 15:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 16:35 ` Re: performance issues Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: Tom Lane @ 2001-06-14 15:51 UTC (permalink / raw)
To: DHSC Webmaster <webmaster@dhs-club.com>; +Cc: pgsql-admin
DHSC Webmaster <webmaster@dhs-club.com> writes:
> Thank you Tom. That has seemed to help substantially.
> I received another sugestion to increase -B 30000 which would give 240
> meg. to postgres. I plan to give that a try. I've already reset the
> SHMMAX val in sysctl to accomodate that size. Do you see any reason not
> to try this? My thought is if some is good, more must be better. :)
Not always; there are several reasons why more can be worse:
1. It's a good idea to leave plenty of free RAM for kernel-level disk
buffering. Postgres has been tuned (to the extent that it is tuned)
to operate with a fair amount of kernel buffering underneath it.
2. If you are on a platform where the kernel thinks it can swap out
parts of shared memory (which is most platforms, these days), it's
counterproductive to make your shared mem large enough that it's not
all being used heavily. If the kernel decides to swap out some buffer
space, you have a net loss in performance, because you just wasted
disk I/O (especially if the page in the buffer is dirty --- it'll
eventually have to be read in again, then written out again, to no
purpose).
3. Also, there are some operations (such as dropping a table) which
cause linear scans of the whole buffer array, so making it too big
can slow things down, depending on your query mix.
While I have not done a lot of measurement to back this up, my rule of
thumb is that you don't want to reserve more than about a quarter of
your physical RAM for Postgres' disk buffers, even on a dedicated
machine. But feel free to experiment and see what results you get.
Please report back if you do any sort of organized tuning experiments;
AFAIK we don't have many hard numbers about these effects.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: performance issues
2001-06-13 13:32 performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-13 14:29 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 14:49 ` Re: performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-14 15:51 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-06-14 16:35 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-16 20:51 ` Re: performance issues Brian McCane <bmccane@mccons.net>
0 siblings, 1 reply; 12+ messages in thread
From: Bruce Momjian @ 2001-06-14 16:35 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: DHSC Webmaster <webmaster@dhs-club.com>; pgsql-admin
> 2. If you are on a platform where the kernel thinks it can swap out
> parts of shared memory (which is most platforms, these days), it's
> counterproductive to make your shared mem large enough that it's not
> all being used heavily. If the kernel decides to swap out some buffer
> space, you have a net loss in performance, because you just wasted
> disk I/O (especially if the page in the buffer is dirty --- it'll
> eventually have to be read in again, then written out again, to no
> purpose).
FYI, FreeBSD had the ability to disable shared memory swapping with a
sysctl setting, while BSD/OS does not swap out shared memory.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: performance issues
2001-06-13 13:32 performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-13 14:29 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 14:49 ` Re: performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-14 15:51 ` Re: performance issues Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 16:35 ` Re: performance issues Bruce Momjian <pgman@candle.pha.pa.us>
@ 2001-06-16 20:51 ` Brian McCane <bmccane@mccons.net>
0 siblings, 0 replies; 12+ messages in thread
From: Brian McCane @ 2001-06-16 20:51 UTC (permalink / raw)
To: pgsql-admin
On Thu, 14 Jun 2001, Bruce Momjian wrote:
> > 2. If you are on a platform where the kernel thinks it can swap out
> > parts of shared memory (which is most platforms, these days), it's
> > counterproductive to make your shared mem large enough that it's not
> > all being used heavily. If the kernel decides to swap out some buffer
> > space, you have a net loss in performance, because you just wasted
> > disk I/O (especially if the page in the buffer is dirty --- it'll
> > eventually have to be read in again, then written out again, to no
> > purpose).
>
> FYI, FreeBSD had the ability to disable shared memory swapping with a
> sysctl setting, while BSD/OS does not swap out shared memory.
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman@candle.pha.pa.us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
I was going to mention this but had to get to my database machine to find
it first. The command is:
sysctl -w kern.ipc.shm_use_phys=1
This is supposed to make shared memory use physical memory, but I don't
think it is a an absolute rule. If you use too much memory, it will still
swap I believe.
- brian
^ permalink raw reply [nested|flat] 12+ messages in thread
* Performance issues
@ 2001-07-16 00:11 Chris Ruprecht <chrup999@yahoo.com>
0 siblings, 0 replies; 12+ messages in thread
From: Chris Ruprecht @ 2001-07-16 00:11 UTC (permalink / raw)
To: pgsql-admin
Hi all,
I have a table with +/- 5.5 million records. There is a column (field) which
has the default value of a sequence. The records get dumped to postgresql
from another database, about 50'000 records at a time, once a day. I read
these records in using the 'load' feature.
Today, I decided to re-sequence all the records, I did this with:
DROP SEQUENCE Seq_PhoneLog;
CREATE SEQUENCE Seq_PhoneLog START 1;
update phonelog set recno = nextval('seq_phonelog') + 1000000000;
update phonelog set recno = recno - 1000000000;
Each of the update statements is taking about 4 hours. I do this in two
steps so there is no problem with records with duplicate numbers which might
already exist. The recno field has a unique index on it.
I checked disk space and it went down from about 25 GB available to 9 GB
available, with a huge number of files getting created in $PGDATA/pg_xlog,
ache 16 MB in size.
Surely, there is something I can do to make this faster. Here are some of
the values I have set in postgres.conf (the rest is not set)
(the machine is a 850 MHz AMD K7 with 768 MB RAM and 2 x 36 GB Ultra
SCSI-160 for data and tmp storage and 1 x 9 GB Ultra SCSI-160 as boot
drive):
#
# Performance
#
#sort_mem = 512
shared_buffers = 1024
#fsync = true
#
# Optimizer Parameters
#
enable_seqscan = true
enable_indexscan = true
enable_tidscan = true
enable_sort = true
enable_nestloop = true
enable_mergejoin = true
enable_hashjoin = true
#ksqo = false
#geqo = true
effective_cache_size = 5000 # default in 8k pages
#random_page_cost = 4
ql_inheritance = true
#
# Deadlock
#
deadlock_timeout = 100
#
# Expression Depth Limitation
#
max_expr_depth = 10000 # min 10
#
# Write-ahead log (WAL)
#
wal_buffers = 32 # min 4
wal_files = 64 # range 0-64
wal_sync_method = fsync # fsync or fdatasync or open_sync or open_datasync
# Note: default wal_sync_method varies across platforms
wal_debug = 0 # range 0-16
commit_delay = 0 # range 0-100000
commit_siblings = 5 # range 1-1000
checkpoint_segments = 3 # in logfile segments (16MB each), min 1
checkpoint_timeout = 300 # in seconds, range 30-3600
#
# Debug display
#
#silent_mode = false
log_connections = true
log_timestamp = true
log_pid = false
#debug_level = 0 # range 0-16
#debug_print_query = false
#debug_print_parse = false
#debug_print_rewritten = false
#debug_print_plan = false
#debug_pretty_print = false
#ifdef USE_ASSERT_CHECKING
#debug_assertions = true
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Performance Issues
@ 2003-09-08 06:13 Ravi T Ramachandra <ravi.ramachandra@wipro.com>
2003-09-08 09:44 ` Re: Performance Issues Nathan <postgresql@phreaker.net>
2003-09-08 12:14 ` Re: Performance Issues Christopher Browne <cbbrowne@acm.org>
2003-09-08 13:13 ` Re: Performance Issues Bruno Wolff III <bruno@wolff.to>
0 siblings, 3 replies; 12+ messages in thread
From: Ravi T Ramachandra @ 2003-09-08 06:13 UTC (permalink / raw)
To: pgsql-admin; +Cc: Sandeep Bhasin <sandeep.bhasin@wipro.com>
Hi,
I recently setup postgres on a Linux box with 4GB Ram and 2.5 GHz
processor. We have created a database with 1.5 million rows in a
table. When we try to select rows from the table, it is taking enormous
time with the default configuration. It takes 2 to 3 seconds to select
1 row that has been selected with indexed columns.
SELECT * FROM TABLE A WHERE COL1 = 1 AND COL2 = 'ABC'.
We have created index definition as follows
CREATE INDEX IDX ON A(COL1, COL2);
Explain on the above statement shows it is sequential scan. The
process size for the postmaster shows as 4MB (is this normal ?)
Thanks for your help in advance,
Regards,
Ravi
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro Limited is
'privileged' and 'confidential' and intended for use only by the individual
or entity to which it is addressed. You are notified that any use, copying
or dissemination of the information contained in the E-MAIL in any manner
whatsoever is strictly prohibited.
***************************************************************************
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Performance Issues
2003-09-08 06:13 Performance Issues Ravi T Ramachandra <ravi.ramachandra@wipro.com>
@ 2003-09-08 09:44 ` Nathan <postgresql@phreaker.net>
2 siblings, 0 replies; 12+ messages in thread
From: Nathan @ 2003-09-08 09:44 UTC (permalink / raw)
To: pgsql-admin
On Mon, Sep 08, 2003 at 11:43:42AM +0530, Ravi T Ramachandra wrote:
> I recently setup postgres on a Linux box with 4GB Ram and 2.5 GHz
> processor.
Big box.
> We have created a database with 1.5 million rows in a
> table.
Small database.
> When we try to select rows from the table, it is taking enormous
> time with the default configuration.
Problem is very probably default configuration (you didn't
say which postgresql version you had, it would have been
interesting, but no matter, or specify that your performance
results were consistent during several runs without reboot, but
I suppose so).
Default configuration is for a small box, or a small database,
or "extremely conservative", whatever. It's "the size that
works for everybody", for some modest value of "work". That's
very different from "one size fits all", and you'll agree that
postgresql can't expect to have 4 GB of RAM to play with on most
machines.
You want to tune performance :-)
To begin with, you want to bump shared_buffers from 64 or
512 to 4096 at the very least, probably all the way to say
32768 or maybe 65536 or even more, I don't know if there's
an upper limit, soft or hard (I've never had more than 1GB
RAM on a machine so I've never wondered <jealous> :-) ) Note
that "cat /proc/sys/kernel/shmmax" should be more or equal to
shared_buffers*8192, otherwise maybe postmaster won't start,
a quick check says that my untuned Linux is at 4096*8192. To
change that, umm, google, yes:
http://www.lyris.com/lm_help/7.5/tuning_postgresql.html
which has a lot of other tips.
Continuing in that vein yields
http://www.varlena.com/GeneralBits/Tidbits/perf.html
http://developer.postgresql.org/docs/postgres/kernel-resources.html
And more in-depth:
http://candle.pha.pa.us/main/writings/pgsql/performance.pdf
http://www.argudo.org/postgresql/soft-tuning.html
If you still have performance problems after a dose of that
medicine I'll be very surprised :-)
Nathan
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Performance Issues
2003-09-08 06:13 Performance Issues Ravi T Ramachandra <ravi.ramachandra@wipro.com>
@ 2003-09-08 12:14 ` Christopher Browne <cbbrowne@acm.org>
2 siblings, 0 replies; 12+ messages in thread
From: Christopher Browne @ 2003-09-08 12:14 UTC (permalink / raw)
To: pgsql-admin
A long time ago, in a galaxy far, far away, ravi.ramachandra@wipro.com ("Ravi T Ramachandra") wrote:
> I recently setup postgres on a Linux box with 4GB Ram and 2.5 GHz
> processor. We have created a database with 1.5 million rows in a
> table. When we try to select rows from the table, it is taking
> enormous time with the default configuration. It takes 2 to 3
> seconds to select 1 row that has been selected with indexed columns.
>
> SELECT * FROM TABLE A WHERE COL1 = 1 AND COL2 = 'ABC'.
>
> We have created index definition as follows
>
> CREATE INDEX IDX ON A(COL1, COL2);
>
> Explain on the above statement shows it is sequential scan. The
> process size for the postmaster shows as 4MB (is this normal ?)
The size seems normal for a database with default parameters. You
might want to do some tuning of parameters in postgresql.conf to
indicate the realistic size of your hardware, instead of its *very*
conservative assumptions.
And as for the SEQ SCAN, there are two most likely reasons:
1. If the query planner thinks that "most" of the rows will be
returned by the query, then it would indeed be preferable to do a seq
scan.
Somehow, I doubt that's the case here, but this sort of thing *does*
happen, and surprises people...
2. Did you ever run ANALYZE on the table to give the query planner
some statistics on what actually is in the table?
If there are no useful stats (in pg_statistic), then the query planner
will do a seq scan because it has no reason to prefer anything else.
Run VACUUM ANALYZE VERBOSE; on the database, and see if that changes
things. I would surely expect it to...
--
select 'cbbrowne' || '@' || 'ntlug.org';
http://cbbrowne.com/info/postgresql.html
"But life wasn't yes-no, on-off. Life was shades of gray, and
rainbows not in the order of the spectrum."
-- L. E. Modesitt, Jr., _Adiamante_
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Performance Issues
2003-09-08 06:13 Performance Issues Ravi T Ramachandra <ravi.ramachandra@wipro.com>
@ 2003-09-08 13:13 ` Bruno Wolff III <bruno@wolff.to>
2 siblings, 0 replies; 12+ messages in thread
From: Bruno Wolff III @ 2003-09-08 13:13 UTC (permalink / raw)
To: Ravi T Ramachandra <ravi.ramachandra@wipro.com>; +Cc: pgsql-admin@postgresql.org, Sandeep Bhasin <sandeep.bhasin@wipro.com>
On Mon, Sep 08, 2003 at 11:43:42 +0530,
Ravi T Ramachandra <ravi.ramachandra@wipro.com> wrote:
>
> SELECT * FROM TABLE A WHERE COL1 = 1 AND COL2 = 'ABC'.
>
> We have created index definition as follows
>
> CREATE INDEX IDX ON A(COL1, COL2);
>
> Explain on the above statement shows it is sequential scan. The
> process size for the postmaster shows as 4MB (is this normal ?)
While Nathan's advice may be useful for you, it probably isn't causing the
problem you are seeing. Your problem is most likely that COL isn't
an INTEGER (aka INT or INT4). Try using single quotes around '1'.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Performance Issues
@ 2003-09-09 07:57 Ravi T Ramachandra <ravi.ramachandra@wipro.com>
0 siblings, 0 replies; 12+ messages in thread
From: Ravi T Ramachandra @ 2003-09-09 07:57 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: pgsql-admin; Sandeep Bhasin <sandeep.bhasin@wipro.com>
Thanks Bruno and Nathan for your responses. The integer column was a
SMALLINT and for some reason, postgres doesn't do index lookup for
smallint. When we changed the column from smallint to int, it is
making lots of differences.
Regards,
Ravi
-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Monday, September 08, 2003 6:43 PM
To: Ravi T Ramachandra
Cc: pgsql-admin@postgresql.org; Sandeep Bhasin
Subject: Re: [ADMIN] Performance Issues
On Mon, Sep 08, 2003 at 11:43:42 +0530,
Ravi T Ramachandra <ravi.ramachandra@wipro.com> wrote:
>
> SELECT * FROM TABLE A WHERE COL1 = 1 AND COL2 = 'ABC'.
>
> We have created index definition as follows
>
> CREATE INDEX IDX ON A(COL1, COL2);
>
> Explain on the above statement shows it is sequential scan. The
> process size for the postmaster shows as 4MB (is this normal ?)
While Nathan's advice may be useful for you, it probably isn't causing
the problem you are seeing. Your problem is most likely that COL isn't
an INTEGER (aka INT or INT4). Try using single quotes around '1'.
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro Limited is
'privileged' and 'confidential' and intended for use only by the individual
or entity to which it is addressed. You are notified that any use, copying
or dissemination of the information contained in the E-MAIL in any manner
whatsoever is strictly prohibited.
***************************************************************************
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2003-09-09 07:57 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-13 13:32 performance issues DHSC Webmaster <webmaster@dhs-club.com>
2001-06-13 14:29 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 14:49 ` DHSC Webmaster <webmaster@dhs-club.com>
2001-06-14 15:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-06-14 16:35 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-16 20:51 ` Brian McCane <bmccane@mccons.net>
2001-07-16 00:11 Performance issues Chris Ruprecht <chrup999@yahoo.com>
2003-09-08 06:13 Performance Issues Ravi T Ramachandra <ravi.ramachandra@wipro.com>
2003-09-08 09:44 ` Re: Performance Issues Nathan <postgresql@phreaker.net>
2003-09-08 12:14 ` Re: Performance Issues Christopher Browne <cbbrowne@acm.org>
2003-09-08 13:13 ` Re: Performance Issues Bruno Wolff III <bruno@wolff.to>
2003-09-09 07:57 Re: Performance Issues Ravi T Ramachandra <ravi.ramachandra@wipro.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox