X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7C081D1C7EB for ; Wed, 6 Aug 2003 11:49:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 12543-09 for ; Wed, 6 Aug 2003 08:48:07 -0300 (ADT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id 00402D1C91D for ; Wed, 6 Aug 2003 08:49:13 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id h76BqYU26791; Wed, 6 Aug 2003 13:52:36 +0200 Received: from gmendola (gmendola.mm.eutelsat.org [194.214.173.50]) by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with SMTP id h76BjOR06400; Wed, 6 Aug 2003 13:45:24 +0200 Message-ID: <006801c35c10$9b55cef0$32add6c2@mm.eutelsat.org> From: "Mendola Gaetano" To: Cc: "Yaroslav Mazurak" References: <3F30AF9E.2080607@lviv.bank.gov.ua> Subject: Re: PostgreSQL performance problem -> tuning Date: Wed, 6 Aug 2003 13:48:06 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/97 X-Sequence-Number: 2914 "Yaroslav Mazurak" > Problem is that SQL statement (see below) is running too long. With > current WHERE clause 'SUBSTR(2, 2) IN ('NL', 'NM') return 25 records. > With 1 record, SELECT time is about 50 minutes and takes approx. 120Mb > RAM. With 25 records SELECT takes about 600Mb of memory and ends after > about 10 hours with error: "Memory exhausted in AllocSetAlloc(32)". Did you try to use a functional index on that field ? create or replace function my_substr(varchar) returns varchar AS' begin return substr($1,2,2); end; ' language 'plpgsql' IMMUTABLE; create index idx on ( my_substr() ); and after you should use in your where: where my_substr() = 'NL'