<div>Thank you for the clarification.</div><div dir="auto"><br></div><div dir="auto">One more question, is it possible that a query result will store in more than one entry? </div><div dir="auto"><br></div><div dir="auto">Thanks, </div><div dir="auto"><br></div><div dir="auto">Avi</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 3 Jan 2023 at 10:43 Tatsuo Ishii <<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Hi,<br>
<br>
> Hi,<br>
> <br>
> I’m a bit confused with the shared memory cache size configuration.<br>
> <br>
> Can you explain the connections between the following configurations:<br>
> <br>
> 1. Memqcache_total_size<br>
> 2. Memqcache_max_num_cache<br>
> 3. Memqcache_block_size<br>
> <br>
> I am not sure how the those configuration works with a correlation to<br>
> entries.<br>
> <br>
> Let say I want blocksize to 2MB<br>
> And I want 1M entries<br>
> How should I configure the proxy in a correlation to the total size?<br>
<br>
That depends on the average query result cache size. You can consult<br>
"show pool_cache" command to know the average cache size. For example,<br>
if you have following "show pool_cache" result:<br>
<br>
num_cache_hits              | 0<br>
num_selects                 | 20<br>
cache_hit_ratio             | 0.00<br>
num_hash_entries            | 1048576<br>
used_hash_entries           | 22<br>
num_cache_entries           | 22<br>
used_cache_entries_size     | 2937<br>
free_cache_entries_size     | 67105927<br>
fragment_cache_entries_size | 0<br>
<br>
the average cache size = used_cache_entries_size/num_cache_entries = 2937/22 = 133.5 (Bytes).<br>
Thus you will need memqcache_total_size = 133.5 * 1M = 139984896 Bytes = 133.5MB.<br>
<br>
> And can you explain more about the calculation for the num entries with the<br>
> multiplication of 48.<br>
<br>
Each cache has "cache header" and "cache body". The cache header is 48<br>
bytes long describing the cache body content, and includes md5 hash<br>
query string. When a query is issued, pgpool searches the cache using<br>
the md5 hash calculated using the query string. See<br>
src/include/query_cache/pool_memqcache.h for more details.<br>
<br>
BTW, while checking the source code to verify the calculation, I<br>
realized that "48" is not actually correct. We also have a hash table<br>
to manage the cache entries. For this we need 12 bytes more for each<br>
cache entry. So the correct calculation constant is 64, not 48. I will<br>
fix the docs soon.<br>
<br>
Best reagards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS LLC<br>
English: <a href="http://www.sraoss.co.jp/index_en/" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en/</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
</blockquote></div></div>