Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id AF4E46358F1 for ; Wed, 14 Apr 2010 11:06: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 93288-05-4 for ; Wed, 14 Apr 2010 14:06:11 +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 997296357E1 for ; Wed, 14 Apr 2010 11:05:35 -0300 (ADT) Received: from [192.168.1.36] by mail.magwerks.com (GMS 15.01.3664/RS2750.00.1b502c7c) with ESMTP id najjeaaa for pgsql-general@postgresql.org; Wed, 14 Apr 2010 10:05:32 -0400 Message-ID: <4BC5CB9D.5050902@magwerks.com> Date: Wed, 14 Apr 2010 10:05:17 -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: Bill Moran CC: "Satish Burnwal (sburnwal)" , pgsql-general@postgresql.org Subject: Re: Query is stuck References: =?utf-8?Q?_<3A8C969225424C4D8E6BEE65ED8552DA0119F188@XMB-BGL-41C.c?= =?utf-8?Q?isco.com>__<20100413091248.a295737b.wmoran@potentialtech.com>=09?= =?utf-8?Q?<3A8C969225424C4D8E6BEE65ED8552DA0119F1AD@XMB-BGL-41C.cisco.com>?= =?utf-8?Q?_<6013c776bd38b7738ff9e43815ce8adc@mail.gransy.com>_<3A8C9692254?= =?utf-8?Q?24C4D8E6BEE65ED8552DA0119F3EE@XMB-BGL-41C.cisco.com>_<2010041408?= =?utf-8?Q?3622.dcf54d70.wmoran@potentialtech.com>_<3A8C969225424C4D8E6BEE6?= =?utf-8?Q?5ED8552DA0119F417@XMB-BGL-41C.cisco.com>_<20100414094203.73aef9b?= =?utf-8?Q?2.wmoran@potentialtech.com>?= In-Reply-To: <20100414094203.73aef9b2.wmoran@potentialtech.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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.288 tagged_above=-10 required=5 tests=AWL=-1.078, BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201004/450 X-Sequence-Number: 161648 On 4/14/2010 9:42 AM, Bill Moran wrote: > > Man, it's hard to read your emails. I've reformatted, I suggest you > improve the formatting on future emails, as I was about to say "to > hell with this question" because it was just too difficult to read, > and I expect there are others on the list who did just that. > I did for the most part. > select report_id, dm_ip, dm_mac, dm_user, > dm_os, report_time, sys_name, > sys_user, sys_user_domain, ss_key, > login_time, role_id, new_vlan_id > from repcopy as a > where report_time = ( > select max(report_time) from repcopy as b > where a.dm_user=b.dm_user and a.dm_ip = b.dm_ip and b.ss_key != '' > ) > and report_status = 0 and dm_user = 'u3'; > > I suggest writting something like this. select report_id, dm_ip, dm_mac, dm_user, dm_os, report_time, sys_name, sys_user, sys_user_domain, ss_key, login_time, role_id, new_vlan_id from repcopy as a (select max(report_time) as rtime, dm_user, dm_ip from repcopy group by dm_user, dm_ip where ss_key != '') as materialized where report_time = materialized.rtime and materialized.dm_user = a.dm_user and materialized.dm__ip = a_ip and report_status = 0 and dm_user = 'u3'; 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.