| From: | "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> |
|---|---|
| To: | "Grant Masan" <grant(dot)massan(at)gmail(dot)com> |
| Cc: | "Jeff Janes" <jeff(dot)janes(at)gmail(dot)com>, <pgsql-performance(at)postgresql(dot)org> |
| Subject: | Re: Problem with database performance, Debian 4gb ram ? |
| Date: | 2009-11-06 15:26:27 |
| Message-ID: | 4AF3EBC3020000250002C329@gw.wicourts.gov |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-performance |
Please keep the list copied.
Grant Masan <grant(dot)massan(at)gmail(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Garry Saddington | 2009-11-06 15:28:43 | Re: pgcrypto |
| Previous Message | Tom Lane | 2009-11-06 14:27:52 | Re: PostgreSQL for 64 Bit Windows Version |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2009-11-06 15:39:27 | Re: Problem with database performance, Debian 4gb ram ? |
| Previous Message | Craig James | 2009-11-06 14:37:38 | Re: Problem with database performance, Debian 4gb ram ? |