Re: for/loop performance in plpgsql ? - Mailing list pgsql-performance

From Tom Lane
Subject Re: for/loop performance in plpgsql ?
Date
Msg-id 17928.1037683436@sss.pgh.pa.us
Whole thread Raw
In response to Re: for/loop performance in plpgsql ?  (Federico <fepede@inwind.it>)
Responses Re: for/loop performance in plpgsql ?  (Federico /* juri */ Pedemonte <fepede@inwind.it>)
List pgsql-performance
Federico <fepede@inwind.it> writes:
>> Well - the query might well be pre-parsed which means it wouldn't notice any
>> updated stats. Can you provide an example of your code?

> It's nothing particular strange. It's something like :

> result record;

> for result in select rai, tem
>                 from data
>                 where (codice LIKE cod_staz and
>                 ora > orain and
>                 ora <= orafin) loop

Which of these names are columns of the selected tables, and which ones
are plpgsql variables?

The planner has to fall back to default selectivity estimates when it's
looking at queries involving plpgsql variables (since it can't know
their actual values in advance).  I suspect your problem is related to
an inaccurate default estimate.

            regards, tom lane

pgsql-performance by date:

Previous
From: Robert Treat
Date:
Subject: Re: selects from large tables
Next
From: Federico /* juri */ Pedemonte
Date:
Subject: Re: for/loop performance in plpgsql ?