Re: simplehash: SH_OPTIMIZE_REPEAT for optimizing repeated lookups of the same key - Mailing list pgsql-hackers

From Andres Freund
Subject Re: simplehash: SH_OPTIMIZE_REPEAT for optimizing repeated lookups of the same key
Date
Msg-id 20231121165138.eoag2db3phqenzj5@awork3.anarazel.de
Whole thread Raw
In response to Re: simplehash: SH_OPTIMIZE_REPEAT for optimizing repeated lookups of the same key  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: simplehash: SH_OPTIMIZE_REPEAT for optimizing repeated lookups of the same key
List pgsql-hackers
Hi,

On 2023-11-20 22:37:47 -0800, Jeff Davis wrote:
> On Mon, 2023-11-20 at 22:50 -0600, Nathan Bossart wrote:
> > I'm mostly thinking out loud here, but could we just always do this? 
> > I
> > guess you might want to avoid it if your SH_EQUAL is particularly
> > expensive
> > and you know repeated lookups are rare, but maybe that's uncommon
> > enough
> > that we don't really care.
> 
> I like that simplehash is simple, so I'm not inclined to introduce an
> always-on feature.

I think it'd be a bad idea to make it always on - there's plenty cases where
it just would make things slower because the hit rate is low. A equal
comparison is far from free.

I am not quite sure this kind of cache best lives in simplehash - ISTM that
quite often it'd be more beneficial to have a cache that you can test more
cheaply higher up.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Locks on unlogged tables are locked?!
Next
From: Jeff Davis
Date:
Subject: Re: Change GUC hashtable to use simplehash?