Re: Function performance degrades after repeated execution

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Function performance degrades after repeated execution
Date: 2019-11-16 15:57:34
Message-ID: CAFj8pRA8uJ9AnOhoDPAPRpU+-Fv-E=v_=U7K3YrxM1rZjwt6ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

so 16. 11. 2019 v 16:46 odesílatel Ron <ronljohnsonjr(at)gmail(dot)com> napsal:

> On 11/16/19 8:22 AM, Dave Roberge wrote:
> > Hi,
> >
> > We've been troubleshooting a slow running function in our postgres
> database. I've been able to boil it down to the simplest function possible.
> It looks like this:
> >
> > FOR rec IN select 1 as matchval FROM table1 t1, table2 t2
> > join table3 t3 on t3.col = t2.col
> > WHERE t1.col = id
> > LOOP
> > IF rec.matchval > 0 THEN
> > co := co + 1;
> > END IF;
> > if co % 100 = 0 then
> > raise notice 'match value %', co;
> > end if;
> > END LOOP;
>
> Where are you joining table1 to either table2 or table3?
>

good shot - there is maybe unwanted cartesian product

Pavel

> --
> Angular momentum makes the world go 'round.
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2019-11-16 17:13:00 Re: PostGreSQL Replication and question on maintenance
Previous Message Ron 2019-11-16 15:45:28 Re: Function performance degrades after repeated execution