Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D7A16632C25 for ; Wed, 14 Apr 2010 10:47:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 08784-06 for ; Wed, 14 Apr 2010 13:47:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.magwerks.com (mail.magwerks.com [209.248.233.131]) by mail.postgresql.org (Postfix) with ESMTP id D7970632BFB for ; Wed, 14 Apr 2010 10:47:20 -0300 (ADT) Received: from [192.168.1.36] by mail.magwerks.com (GMS 15.01.3664/RS2750.00.1b502c7c) with ESMTP id pvijeaaa for pgsql-general@postgresql.org; Wed, 14 Apr 2010 09:47:18 -0400 Message-ID: <4BC5C759.40403@magwerks.com> Date: Wed, 14 Apr 2010 09:47:05 -0400 From: Justin Graf User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: pgsql-general@postgresql.org, "Satish Burnwal (sburnwal)" , Bill Moran Subject: Re: Query is stuck References: =?utf-8?Q?_<3A8C969225424C4D8E6BEE65ED8552DA0119F188@XMB-BGL-41C.c?= =?utf-8?Q?isco.com><20100413091248.a295737b.wmoran@potentialtech.com><3A8C9692?= =?utf-8?Q?25424C4D8E6BEE65ED8552DA0119F1AD@XMB-BGL-41C.cisco.com><6013c776bd?= =?utf-8?Q?38b7738ff9e43815ce8adc@mail.gransy.com><3A8C969225424C4D8E6BEE65ED?= =?utf-8?Q?8552DA0119F3EE@XMB-BGL-41C.cisco.com>_<20100414083622.dcf54d70.w?= =?utf-8?Q?moran@potentialtech.com>_<3A8C969225424C4D8E6BEE65ED8552DA0119F4?= =?utf-8?Q?17@XMB-BGL-41C.cisco.com>?= In-Reply-To: <3A8C969225424C4D8E6BEE65ED8552DA0119F417@XMB-BGL-41C.cisco.com> Content-Type: multipart/alternative; boundary="------------020101020409080908060301" X-AntiSpam: Checked for restricted content by Gordano's AntiSpam Software X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.377 tagged_above=-10 required=5 tests=AWL=-1.168, BAYES_50=0.8, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201004/446 X-Sequence-Number: 161644 This is a multi-part message in MIME format. --------------020101020409080908060301 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 4/14/2010 9:20 AM, Satish Burnwal (sburnwal) wrote: > Index Scan using repcopy_index on repcopy a (cost=0.00..87824607.17 > *rows=28* width=142) (actual time=11773.105..689111.440*rows=1* loops=1) > Index Cond: ((dm_user)::text = 'u3'::text) > Filter: ((report_status = 0) AND (report_time = (subplan))) > SubPlan > -> Aggregate (cost=3531.30..3531.31 rows=1 width=8) (actual > time=58.447..58.448 rows=1 loops=11788) > -> Index Scan using repcopy_index on repcopy b > (cost=0.00..3526.30*rows=2000* width=8) (actual time=0.017..36.779 > *rows=25842* loops=11788) > Index Cond: ((($0)::text = (dm_user)::text) AND > (($1)::text = (dm_ip)::text)) > Filter: ((ss_key)::text<> ''::text) > Total runtime: 689111.511 ms > (9 rows) > The estimated cost and actual are way off. Have you run Analyze on the table you may want to change the statistics collected for this table http://www.postgresql.org/docs/8.1/static/planner-stats.html ALTER [ COLUMN ]/column/ SET STATISTICS/integer/ http://www.postgresql.org/docs/8.1/static/sql-altertable.html All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by our proprietary quotation system. Quotations received via any other form of communication will not be honored. CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other information proprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it addresses. If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified that any unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this e-mail immediately. Thank you. --------------020101020409080908060301 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit On 4/14/2010 9:20 AM, Satish Burnwal (sburnwal) wrote:
 Index Scan using repcopy_index on repcopy a  (cost=0.00..87824607.17
rows=28 width=142) (actual time=11773.105..689111.440 rows=1 loops=1)
   Index Cond: ((dm_user)::text = 'u3'::text)
   Filter: ((report_status = 0) AND (report_time = (subplan)))
   SubPlan
     ->  Aggregate  (cost=3531.30..3531.31 rows=1 width=8) (actual
time=58.447..58.448 rows=1 loops=11788)
           ->  Index Scan using repcopy_index on repcopy b
(cost=0.00..3526.30 rows=2000 width=8) (actual time=0.017..36.779
rows=25842 loops=11788)
                 Index Cond: ((($0)::text = (dm_user)::text) AND
(($1)::text = (dm_ip)::text))
                 Filter: ((ss_key)::text <> ''::text)
 Total runtime: 689111.511 ms
(9 rows)
  

The estimated cost and actual are way off.  Have you run Analyze on the table

you may want to change the statistics collected for this table
 
http://www.postgresql.org/docs/8.1/static/planner-stats.html

 ALTER [ COLUMN ] column SET STATISTICS integer
http://www.postgresql.org/docs/8.1/static/sql-altertable.html



All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by our proprietary quotation system. Quotations received via any other form of communication will not be honored.

CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other information proprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it addresses. If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified that any unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this e-mail immediately.
Thank you.
--------------020101020409080908060301--