Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0XmS-0003QE-Rq for pgsql-general@arkaria.postgresql.org; Wed, 30 Jan 2013 13:32:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U0XmR-0004Lg-Uh for pgsql-general@arkaria.postgresql.org; Wed, 30 Jan 2013 13:32:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0XmQ-0004La-JV for pgsql-general@postgresql.org; Wed, 30 Jan 2013 13:32:46 +0000 Received: from mailout11.t-online.de ([194.25.134.85]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0XmM-00071n-Pm for pgsql-general@postgresql.org; Wed, 30 Jan 2013 13:32:46 +0000 Received: from fwd04.aul.t-online.de (fwd04.aul.t-online.de ) by mailout11.t-online.de with smtp id 1U0XmK-0000MU-Do; Wed, 30 Jan 2013 14:32:40 +0100 Received: from musicman.homeip.net (GMEGvkZrghSUsUwbMM+gUlvC3EU4fIX426Wc37KO1MwbUnpJLh8oOTWbfl+bB0zg-A@[93.233.100.235]) by fwd04.aul.t-online.de with esmtp id 1U0XmI-0MYYk40; Wed, 30 Jan 2013 14:32:38 +0100 Received: (qmail 5379 invoked by uid 1000); 30 Jan 2013 13:32:37 -0000 From: hamann.w@t-online.de Date: Wed, 30 Jan 2013 14:32:37 +0100 To: pgsql-general@postgresql.org Subject: Re: optimize query? Message-ID: <510920F5.mailx43Y11TD0Y@amadeus3.local> User-Agent: nail 10.5 4/27/03 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ID: GMEGvkZrghSUsUwbMM+gUlvC3EU4fIX426Wc37KO1MwbUnpJLh8oOTWbfl+bB0zg-A X-TOI-MSGID: d76f12b4-738f-41c2-9107-cd13d091d9bb X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Bob Futrelle wrote: If looking for the variants with a single suffixed character is all you'll ever need to do: Do a single pass on the large table, after creating a field, 'trunc' that contains a truncated version of the item, e.g., adding XY423 to trunc for each entry of the form XY423A, or XY423B, etc. This would be a one-time operation. Hi Bob, unfortunately it is not because the suffix pattern is not always the same. On the other hand, I tried to split the query into select substring (code from '^[A-Z]+[0-9]+') as code into tmp table t select .... where tab2.code = t.code which definitely was a big improvement. I believe that most of the time passing in a pattern like that would work So thank you for that tip Regards Wolfgang -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general