Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 1CA76930E1F for ; Fri, 3 Aug 2012 21:38:55 -0300 (ADT) Received: from nm24.access.bullet.mail.mud.yahoo.com ([66.94.237.89]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SxSOJ-000289-EZ for pgsql-performance@postgresql.org; Sat, 04 Aug 2012 00:38:55 +0000 Received: from [66.94.237.201] by nm24.access.bullet.mail.mud.yahoo.com with NNFMP; 04 Aug 2012 00:38:37 -0000 Received: from [98.139.221.52] by tm12.access.bullet.mail.mud.yahoo.com with NNFMP; 04 Aug 2012 00:38:37 -0000 Received: from [127.0.0.1] by smtp105.sbc.mail.bf1.yahoo.com with NNFMP; 04 Aug 2012 00:38:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s1024; t=1344040717; bh=N73jU+7CWFk7ClW9YHTzmG6I8lhdxUJ8JK940VUCzME=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:From:To:Subject:Date:MIME-Version:Content-Type:X-Priority:X-MSMail-Priority:X-Mailer:X-MimeOLE; b=UT16KPeuNLqJC5/XZ3A/UFnVDuHOASnoM1qSKs16npBE+jytBvXyI/r4thP6inXQAK3gJaqN64e0vLL6uBfpwomuAqBL8doZ70rkmRoJH+AssX7ftP74HE10ZyHAYwH76fck2uKEEird2Czuvxuxm5ig6LlzDx1pvh9eK3CpbOM= X-Yahoo-Newman-Id: 455692.49095.bm@smtp105.sbc.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: GAIdNDYVM1mOsdZfi3ZUD4jWQaK7OUsgZSeDLpxrLu8n2AR Wg5T_tLJU7oJW9M1jiDJMrbvrIMRPKOBnWeXlL7IH6BNBq7725JRXswZL4Hc lmh6VBPPQxUrvs6Ymkff_8qEzKMYCZlUlbQwF53ZZLgAdjfc9MmMOehIjUH7 H477fMUGHJjOFlatm3YzImgsoTjQocCdMMPE0N0OWFz9y5Nm.t72SyhdKanc mwOm7G_HXB_Wk4N07qml4bl6OiU2sDU7oKs7fOmoZMUkAU4IvVzgmA6VBEdy xqpzT_6_qe0aNoOI87ekBYvyUDY2j2lLXcJHRKHYquubme7OfOtGDEuyNd3J hTaCTeN24I6gJLvhKU55XqjlaMG3GNj2lSArO8Wb8CpPC86WTXskfLJbG4Fg cSDdNuMaoyqJV6bgoauR9q96s_OonC.mphQdXAu9u748coOYnJpIi3aKQ22W 84fG8NjuCzc7qwhAmzlbeljZoZBZhAXmZJgde791p.AmPyyE6AVAaMfb0Ph0 XpkojjiCgZ2PiLF7NnS4EXwdp4t8IvLVqR2JpXtL2tA-- X-Yahoo-SMTP: EtaTb4uswBBSx2FARGS8Y34d19mAO_hWIqN6lfRu55otbg-- Received: from BERNICE (midgems@71.135.44.53 with login) by smtp105.sbc.mail.bf1.yahoo.com with SMTP; 03 Aug 2012 17:38:36 -0700 PDT Message-ID: <9CF5A680782142D794A085320949FED4@BERNICE> From: "Midge Brown" To: Subject: slow query, different plans Date: Fri, 3 Aug 2012 17:38:33 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00F7_01CD719E.CDE01A80" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Pg-Spam-Score: -2.0 (--) X-Archive-Number: 201208/17 X-Sequence-Number: 47555 This is a multi-part message in MIME format. ------=_NextPart_000_00F7_01CD719E.CDE01A80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm having a problem with a query on our production server, but not on a la= ptop running a similar postgres version with a recent backup copy of the sa= me table. I tried reindexing the table on the production server, but it did= n't make any difference. Other queries on the same table are plenty fast.= =20 This query has been slow, but never like this, particularly during a period= when there are only a couple of connections in use.=20 Vacuum and analyze are run nightly (and show as such in pg_stat_user_tables= ) in addition to autovacuum during the day. Here are my autovacuum settings= , but when I checked last_autovacuum & last_autoanalyze in pg_stat_user_tab= les those fields were blank.=20 autovacuum =3D on=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20 log_autovacuum_min_duration =3D 10=20=20=20=20=20=20=20=20 autovacuum_max_workers =3D 3=20=20=20=20=20=20=20=20=20=20=20=20=20=20 autovacuum_naptime =3D 1min=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 autovacuum_vacuum_threshold =3D 50=20=20=20=20=20=20=20=20 autovacuum_analyze_threshold =3D 50=20=20=20=20=20=20=20 autovacuum_vacuum_scale_factor =3D 0.2=20=20=20=20 autovacuum_analyze_scale_factor =3D 0.1=20=20=20 autovacuum_freeze_max_age =3D 200000000=20=20=20 autovacuum_vacuum_cost_delay =3D 10ms (changed earlier today from 1000ms)= =20=20 autovacuum_vacuum_cost_limit =3D -1 wal_level =3D minimal wal_buffers =3D 16MB The only recent change was moving the 3 databases we have from multiple rai= d 1 drives with tablespaces spread all over to one large raid10 with indexe= s and data in pg_default. WAL for this table was moved as well. Does anyone have any suggestions on where to look for the problem?=20=20 clientlog table info: Size: 1.94G Column | Type | Modifiers=20 ----------+-----------------------------+----------- pid0 | integer | not null rid | integer | not null verb | character varying(32) | not null noun | character varying(32) | not null detail | text |=20 path | character varying(256) | not null ts | timestamp without time zone |=20 applies2 | integer |=20 toname | character varying(128) |=20 byname | character varying(128) |=20 Indexes: "clientlog_applies2" btree (applies2) "clientlog_pid0_key" btree (pid0) "clientlog_rid_key" btree (rid) "clientlog_ts" btree (ts) The query, hardware info, and links to both plans: explain analyze select max(ts) as ts from clientlog where applies2=3D256; Production server: - 4 dual-core AMD Opteron 2212 processors, 2010.485 MHz - 64GB RAM - 464GB RAID10 drive=20 - Linux 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86= _64 GNU/Linux PostgreSQL 9.0.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.= 1.2 20080704 (Red Hat 4.1.2-46), 64-bit http://explain.depesz.com/s/8R4 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20