From: Mendola Gaetano <mendola@bigfoot.com>
To: pgsql-performance@postgresql.org
Cc: Yaroslav Mazurak <yamazurak@Lviv.Bank.Gov.UA>
Subject: Re: PostgreSQL performance problem -> tuning
Date: Wed, 6 Aug 2003 13:48:06 +0200
Message-ID: <006801c35c10$9b55cef0$32add6c2@mm.eutelsat.org> (raw)
References: <3F30AF9E.2080607@lviv.bank.gov.ua>
"Yaroslav Mazurak" <yamazurak@Lviv.Bank.Gov.UA>
> 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 <table> ( my_substr(<field>) );
and after you should use in your where:
where my_substr(<field>) = 'NL'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: mendola@bigfoot.com, yamazurak@Lviv.Bank.Gov.UA
Subject: Re: PostgreSQL performance problem -> tuning
In-Reply-To: <006801c35c10$9b55cef0$32add6c2@mm.eutelsat.org>
References: <3F30AF9E.2080607@lviv.bank.gov.ua> <006801c35c10$9b55cef0$32add6c2@mm.eutelsat.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox