Improve cache hit rate for OprCacheHash

Поиск
Список
Период
Сортировка
От myzhen
Тема Improve cache hit rate for OprCacheHash
Дата
Msg-id 301aaca2.1861.198d17e0ed3.Coremail.zhenmingyang@yeah.net
обсуждение исходный текст
Ответы Re: Improve cache hit rate for OprCacheHash
Список pgsql-hackers
Dear Hackers,
The order of all schemas in OprCacheKey.search_path should be meaningless. If we sort the search_path when constructing OprCacheKey, we can improve the hit rate of the operator cache (OprCacheHash). Otherwise, when the number and content of schemas in the search_path remain unchanged but the order of the schemas is different, the cache cannot be hit and an extra entry is wasted.
A possible example:
set search_path to schema1, schema2;
select * from test where col = 123; -- insert cache item for the first time.
select * from test where col = 123; -- cache hit.
set search_path to schema2, schema1; -- schema order change.
select * from test where col = 123; -- cache search failed, add a new cache item.

Add at the end of the make_oper_cache_key function:
qsort(key->search_path, MAX_CACHED_PATH_LEN, sizeof(Oid), oid_cmp);

I'm not sure if my understanding is correct or if it's worth making the change.

thanks!

regards

В списке pgsql-hackers по дате отправления: