Re: Postgres not using index on views - Mailing list pgsql-performance

From Thomas Kellerer
Subject Re: Postgres not using index on views
Date
Msg-id e24f881c-2475-2ad9-ca12-fa594a057196@gmx.net
Whole thread Raw
In response to RE: Postgres not using index on views  (Rick Vincent <rvincent@temenos.com>)
List pgsql-performance
Rick Vincent schrieb am 07.04.2020 um 11:08:
> The function is defined as below, so no use of VOLATILE.

If you don't specify anything, the default is VOLATILE.

So your function *is* volatile.
 
> CREATE OR REPLACE FUNCTION extractValueJS (sVar text, nfm INTEGER, nvm INTEGER)
> RETURNS VARCHAR as $$
> declare
> sRet text := '';
> nSize int := 0;
> retVal int := 0;
> cVar text[] := regexp_split_to_array(sVar,'');
> idx int := 1;
> nStart int := 0;
> nEnd int := 0;
> begin
> etc...
>         return sRet;
> end;
> $$ LANGUAGE plpgsql;

You haven't shown us your actual code, but if you can turn that into a "language sql" function (defined as immutable,
orat least stable), I would expect it to be way more efficient. 

Thomas



pgsql-performance by date:

Previous
From: Rick Vincent
Date:
Subject: RE: Postgres not using index on views
Next
From: Thomas Kellerer
Date:
Subject: Re: Postgres not using index on views