From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Grant Masan <grant.massan@gmail.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Problem with database performance, Debian 4gb ram ?
Date: Fri, 06 Nov 2009 09:26:27 -0600
Message-ID: <4AF3EBC3020000250002C329@gw.wicourts.gov> (raw)
In-Reply-To: <c09b5d640911052239q44b42ddbv3312d9af560267f3@mail.gmail.com>
References: <c09b5d640911020616t7177a7b9sb4b5f285d99e7c05@mail.gmail.com>
<4AEFF447020000250002C19D@gw.wicourts.gov>
<f67928030911030923i31663c7ew8d75b04874cb568d@mail.gmail.com>
<4AF019E6020000250002C1D2@gw.wicourts.gov>
<c09b5d640911052239q44b42ddbv3312d9af560267f3@mail.gmail.com>
Please keep the list copied.
Grant Masan <grant.massan@gmail.com> wrote:
> CREATE FUNCTION ... RETURNS SETOF ...
> FOR ... IN SELECT ... LOOP
> FOR ... IN SELECT ... LOOP
> FOR ... IN SELECT ... LOOP
>
> RETURN NEXT text_output;
>
> END LOOP;
> END LOOP;
> END LOOP;
I don't have time to work through the logic of all this to try to
discern what your goal is; but in my experience, such procedural code
can usually be rewritten as a single query. The results are typically
orders of magnitude better.
> SELECT * FROM info_tool(linest,date,date)
> "Function Scan on info_tool (cost=0.00..260.00 rows=1000 width=108)
> (actual time=437712.611..437712.629 rows=14 loops=1)"
> "Total runtime: 437712.686 ms"
To get useful information you need EXPLAIN ANALYZE from statements
inside the function, not of the execution of the function.
-Kevin
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, grant.massan@gmail.com, jeff.janes@gmail.com
Subject: Re: Problem with database performance, Debian 4gb ram ?
In-Reply-To: <4AF3EBC3020000250002C329@gw.wicourts.gov>
* 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