Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id D69542E004E for ; Tue, 20 May 2008 03:24:47 -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 12596-05-5 for ; Tue, 20 May 2008 03:24:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by developer.postgresql.org (Postfix) with ESMTP id 9E3AB2E0058 for ; Tue, 20 May 2008 03:15:51 -0300 (ADT) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis) id 0ML2xA-1JyL8X21jM-0005au; Tue, 20 May 2008 08:15:50 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1JyL8W-00088j-00 for pgsql-performance@postgresql.org; Tue, 20 May 2008 08:15:48 +0200 Date: Tue, 20 May 2008 08:15:48 +0200 From: "A. Kretschmer" To: pgsql-performance@postgresql.org Subject: Re: slow update Message-ID: <20080520061548.GA29403@a-kretschmer.de> References: <468CEDC5-0707-4C5F-880F-45A75330731A@kevinkempterllc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <468CEDC5-0707-4C5F-880F-45A75330731A@kevinkempterllc.com> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1/cFc5A1BG0xw7lt1FUpylLcmbCIJKYyxa1v7W U5R4he8djgDf07l/f4nsLD7/zGKJLnkM1aYxAH/8dDFICpTSR1 UxhKxxMBpkT8YncNFhfwVFyM9MVFiAd X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/272 X-Sequence-Number: 30240 am Mon, dem 19.05.2008, um 23:56:27 -0600 mailte kevin kempter folgendes: > 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); > > > The current_run_date table has only 1 row in it > the summary_tab table has 0 rows and the tab_x had 450,000 rows > > The update takes 45min even though there is no rows to update. > I have a compound index (cust_id, loc_id) on both tables (summary_tab > and tab_x) > > How can I speed this up ? Please show us more details, for instance the data-types for cust_id and loc_id. Wild guess: these columns are INT-Values and you have an Index. Okay, but in the quere there is a CAST to TEXT -> Index not used. Verfify this with EXPLAIN. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net