Re: Is it safe to cache data by GiST consistent function

2024-04-03 Thread Michał Kłeczek
> On 3 Apr 2024, at 19:02, Tom Lane wrote: > > =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: > >> pg_trgm consistent caches tigrams but it has some logic to make sure cached >> values are recalculated: > >> cache = (gtrgm_consistent_cache *) fcinfo->flinfo->fn_extra; >> if (cache =

Re: Is it safe to cache data by GiST consistent function

2024-04-03 Thread Tom Lane
=?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: > On 3 Apr 2024, at 16:27, Tom Lane wrote: >> AFAIK it works. I don't see any of the in-core ones doing so, >> but at least range_gist_consistent and multirange_gist_consistent >> are missing a bet by repeating their cache search every time. > pg_trg

Re: Is it safe to cache data by GiST consistent function

2024-04-03 Thread Michał Kłeczek
Thanks for taking your time to answer. Not sure if I understand though. > On 3 Apr 2024, at 16:27, Tom Lane wrote: > > =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: >> When implementing a GiST consistent function I found the need to cache >> pre-processed query across invocations. >> I am not s

Re: Is it safe to cache data by GiST consistent function

2024-04-03 Thread Tom Lane
=?utf-8?Q?Micha=C5=82_K=C5=82eczek?= writes: > When implementing a GiST consistent function I found the need to cache > pre-processed query across invocations. > I am not sure if it is safe to do (or I need to perform some steps to make > sure cached info is not leaked between rescans). AFAIK i

Is it safe to cache data by GiST consistent function

2024-04-02 Thread Michał Kłeczek
Hello, When implementing a GiST consistent function I found the need to cache pre-processed query across invocations. I am not sure if it is safe to do (or I need to perform some steps to make sure cached info is not leaked between rescans). The comment in gistrescan says: /*