Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9348B633479 for ; Tue, 13 Apr 2010 11:47:22 -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 86035-06 for ; Tue, 13 Apr 2010 14:47:02 +0000 (UTC) X-Greylist: delayed 00:21:05.615769 by SQLgrey-1.7.6 Received: from mail.gransy.com (nathalia.gransy.com [82.208.29.194]) by mail.postgresql.org (Postfix) with ESMTP id C055A63326C for ; Tue, 13 Apr 2010 11:47:11 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.gransy.com (Postfix) with ESMTP id C9CC72E5A06D; Tue, 13 Apr 2010 16:26:02 +0200 (CEST) Received: from mail.gransy.com ([127.0.0.1]) by localhost (nathalia.gransy.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O--CENTPAlI4; Tue, 13 Apr 2010 16:26:02 +0200 (CEST) Received: from rc.gransy.com (anastacia.gransy.com [77.78.104.100]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTP id D67072E5A064; Tue, 13 Apr 2010 16:25:59 +0200 (CEST) MIME-Version: 1.0 Date: Tue, 13 Apr 2010 16:25:59 +0200 From: To: "Satish Burnwal (sburnwal)" Cc: Bill Moran , Subject: Re: [ADMIN] Query is stuck In-Reply-To: <3A8C969225424C4D8E6BEE65ED8552DA0119F1AD@XMB-BGL-41C.cisco.com> References: <3A8C969225424C4D8E6BEE65ED8552DA0119F188@XMB-BGL-41C.cisco.com> <20100413091248.a295737b.wmoran@potentialtech.com> <3A8C969225424C4D8E6BEE65ED8552DA0119F1AD@XMB-BGL-41C.cisco.com> Message-ID: <6013c776bd38b7738ff9e43815ce8adc@mail.gransy.com> X-Sender: tv@fuzzy.cz User-Agent: RoundCube Webmail/0.2.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="UTF-8" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.553 tagged_above=-10 required=5 tests=AWL=0.347, BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201004/404 X-Sequence-Number: 161602 > INFO: "repcopy": scanned 3000 of 4652 pages, containing 128964 live rows > and 0 dead rows; 3000 rows in sample, 199980 estimated total rows > VACUUM > controlsmartdb=# select distinct report_status from repcopy ; According to the vacuum output, there are about 200000 rows in the "repcopy" table, occupying roughly 40MB. And according to the explain plan you've posted earlier, there's a seq scan for each row - that gives 200000 sequential scans on the table ... which is about 8TB of data. Sure, most of the data will be read from disk cache / shared buffers etc. but still it's a lot of data to process - that's why it takes so long. I'd recommend creating a index on (dm_user, dm_ip) columns, but it depends on how many different values are in these columns (the more the better). What information do we need to give better recommendations: 1) info about structure of the "repcopy" table (column data types, indexes) 2) info about data (how many different values are there) 3) what does the system do when running the query (use 'top' or 'dstat' to get iowait / CPU / disk / memory etc.) regards Tomas