Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 0F15D2E005E for ; Tue, 20 May 2008 14:47:25 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50224-01 for ; Tue, 20 May 2008 14:47:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.239]) by developer.postgresql.org (Postfix) with ESMTP id 1E5E42E0058 for ; Tue, 20 May 2008 14:47:16 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id 76so1213516wra.10 for ; Tue, 20 May 2008 10:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=85VrrDYm3egByZ5sjfIdz+Gjyj4k3LmYgjI8zOFOVC4=; b=UxYZmf2/1AS/7dzGQCzHKNz9fczbr1yXSNeBqHvBfcbZLZBcM0Q7+cSw/kkwl1UvdhGazPjyXCoQQSjSDyJ0xjqKTPfJJhaXLzc0nmsT4kU8xLvRiJSliMOAODN704VwxBb2feY4I4VRws648Y/duTHNgQXasYs9cUsPXmzHy44= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=cMx+BKxKjQzSfEdbVRX5/g0QydfL3xT0m9V59SEJc3ntAvxIpypkzExJNRZDrhwss+CAfPbodwoF7P3cQESNCTAHSvs8OJXR6pfMJGknlRCzX0qZDb1wjwmIMjp4sXhVnvDO22pm2godju9lAowKGgRG0FBMJqW5quWP3TZSOgU= Received: by 10.115.93.16 with SMTP id v16mr9135301wal.185.1211305633429; Tue, 20 May 2008 10:47:13 -0700 (PDT) Received: by 10.114.137.7 with HTTP; Tue, 20 May 2008 10:47:13 -0700 (PDT) Message-ID: Date: Tue, 20 May 2008 11:47:13 -0600 From: "Scott Marlowe" To: "kevin kempter" Subject: Re: slow update Cc: pgsql-performance@postgresql.org In-Reply-To: <468CEDC5-0707-4C5F-880F-45A75330731A@kevinkempterllc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <468CEDC5-0707-4C5F-880F-45A75330731A@kevinkempterllc.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/275 X-Sequence-Number: 30243 On Mon, May 19, 2008 at 11:56 PM, kevin kempter wrote: > Hi all; > > I have a query that does this: > > update tab_x set (inactive_dt, last_update_dt) = > ((select run_dt from current_run_date), (select run_dt from > current_run_date)) > where > cust_id::text || loc_id::text in > (select cust_id::text || loc_id::text from summary_tab); I think what you're looking for in the where clause is something like: where (cust_id, loc_id) in (select cust_id, loc_id from summary_tab); which should let it compare the native types all at once. Not sure if this works on versions before 8.2 or not. If you MUST use that syntax, then create indexes on them, i.e.: create index tab_x_multidx on tab_x ((cust_id::text||loc_id::text)); create index summary_tab_x_multidx on summary_tab ((cust_id::text||loc_id::text));