Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 96E2E1337BB7 for ; Wed, 30 Mar 2011 16:45:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 81928-02 for ; Wed, 30 Mar 2011 19:45:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qmta14.westchester.pa.mail.comcast.net (qmta14.westchester.pa.mail.comcast.net [76.96.59.212]) by mail.postgresql.org (Postfix) with ESMTP id 84EBB1337BB4 for ; Wed, 30 Mar 2011 16:45:16 -0300 (ADT) Received: from omta24.westchester.pa.mail.comcast.net ([76.96.62.76]) by qmta14.westchester.pa.mail.comcast.net with comcast id RXMz1g0051ei1Bg5EXlHgu; Wed, 30 Mar 2011 19:45:17 +0000 Received: from [192.168.1.3] ([98.225.18.133]) by omta24.westchester.pa.mail.comcast.net with comcast id RXlG1g00Z2sG8du3kXlGkD; Wed, 30 Mar 2011 19:45:17 +0000 Message-ID: <4D938846.6080008@comcast.net> Date: Wed, 30 Mar 2011 12:45:10 -0700 From: Harry Rossignol User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Re: Postgres not using indexes References: <965AA5440EAC094E9F722519E285ACEDAC5E66A53D@WWCEXCHANGE.web.web.com> <4D9317D3020000250003BF7B@gw.wicourts.gov> <965AA5440EAC094E9F722519E285ACEDAC5E66A556@WWCEXCHANGE.web.web.com> <4D9322E8020000250003BF8C@gw.wicourts.gov> <965AA5440EAC094E9F722519E285ACEDAC5E66A566@WWCEXCHANGE.web.web.com> In-Reply-To: <965AA5440EAC094E9F722519E285ACEDAC5E66A566@WWCEXCHANGE.web.web.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.345 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201103/396 X-Sequence-Number: 29906 I'm just a lowly end user. Bumping the default statistics target or using ALTER TABLE SET STATISTICS has made large differences in query performance on large tables. The query planner has to guesstimate using the statistics. Sometimes on large tables the guesstimate isn't very good with a small statistical sample. On 3/30/2011 12:05 PM, Lawrence Cohan wrote: > I think you are right (my bad) and please see the results below plus a little bit more info about the environment and sorry I missed that before. I've been told the server was tuned to the best for what we need and looks like we will need to change at least the two values below and maybe play with work_mem to see if it solves our issues. > The only issue is that we are running a 24/7 web site against the db and if we need to restart PG for the changes to take place we will need to wait for a downtime before any changes can be made. > > 'shared_buffers';'500MB' - shared_buffers should be 10% to 25% of available RAM -> change it to 2GB > 'effective_cache_size';'2GB' - effective_cache_size should be 75% of available RAM -> change it to 10GB > 'work_mem';'1MB' - increase it to 8MB, 32MB, 256MB, 1GB and check if better results. > > > PostgreSQL 9.0.2 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 64-bit > 2 x Intel(R) Xeon(R) CPU E5345 @ 2.33GHz > 4 x 4GB = 16GB RAM > > --query results below: > 'version';'PostgreSQL 9.0.2 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 64-bit' > 'archive_command';'cp %p /pglog/wal_export/%f' > 'archive_mode';'on' > 'archive_timeout';'3min' > 'autovacuum_analyze_threshold';'1000' > 'autovacuum_vacuum_threshold';'1000' > 'bytea_output';'escape' > 'checkpoint_segments';'64' > 'checkpoint_warning';'1min' > 'client_encoding';'UNICODE' > 'effective_cache_size';'2GB' > 'escape_string_warning';'off' > 'lc_collate';'en_US.UTF-8' > 'lc_ctype';'en_US.UTF-8' > 'listen_addresses';'xxx.xxx.xxx.xxx' > 'log_autovacuum_min_duration';'2s' > 'log_checkpoints';'on' > 'log_destination';'syslog' > 'log_line_prefix';'user=%u,db=%d' > 'log_min_duration_statement';'1s' > 'maintenance_work_mem';'256MB' > 'max_connections';'1200' > 'max_stack_depth';'2MB' > 'port';'5432' > 'server_encoding';'UTF8' > 'shared_buffers';'500MB' > 'syslog_facility';'local0' > 'syslog_ident';'postgres' > 'TimeZone';'Canada/Eastern' > 'vacuum_cost_delay';'10ms' > 'wal_buffers';'4MB' > 'wal_level';'hot_standby' > > > -----Original Message----- > From: Kevin Grittner [mailto:Kevin.Grittner@wicourts.gov] > Sent: March-30-11 1:33 PM > To: pgsql-bugs@postgresql.org; Lawrence Cohan > Subject: RE: [BUGS] Postgres not using indexes > > Lawrence Cohan wrote: >> From: Kevin Grittner [mailto:Kevin.Grittner@wicourts.gov] >>> [configuration advice] >>> If, after reading the above-cited page and tuning your server you >>> still have performance problems, pick one query to work on first, >>> and follow the step outlined here: >>> >>> http://wiki.postgresql.org/wiki/SlowQueryQuestions >> We thank you for the links that have a lots of info and please >> note that we tuned our servers as recommended by Enterprise DB >> experts while they were in house for our hardware/software >> migrations and the setting you mentioned are in place already. > Then the next step would be to provide enough information on one of > the slow queries for people to be able to offer useful advice. Your > other post showed the query and the EXPLAIN ANALYZE output, but the > other information listed in the above-cited page is useful when > trying to understand a problem. I'm particularly curious about the > data types of the id columns and the specifics of the index > definitions. > > -Kevin > > Attention: > The information contained in this message and or attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any system and destroy any copies. >