Skip to content

Commit 6c1f534

Browse files
committed
Move caches to Shared Memory
This will let backends share them.
1 parent 20bb5ad commit 6c1f534

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/backend/utils/cache/ag_cache.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "catalog/pg_collation.h"
3131
#include "fmgr.h"
3232
#include "storage/lockdefs.h"
33+
#include "storage/shmem.h"
3334
#include "utils/builtins.h"
3435
#include "utils/catcache.h"
3536
#include "utils/fmgroids.h"
@@ -236,8 +237,8 @@ static void create_graph_name_cache(void)
236237
* Please see the comment of hash_create() for the nelem value 16 here.
237238
* HASH_BLOBS flag is set because the key for this hash is fixed-size.
238239
*/
239-
graph_name_cache_hash = hash_create("ag_graph (name) cache", 16, &hash_ctl,
240-
HASH_ELEM | HASH_BLOBS | HASH_COMPARE);
240+
graph_name_cache_hash = ShmemInitHash("ag_graph (name) cache",16, 1000, &hash_ctl,
241+
HASH_ELEM | HASH_BLOBS | HASH_COMPARE);
241242
}
242243

243244
static void create_graph_namespace_cache(void)
@@ -252,7 +253,7 @@ static void create_graph_namespace_cache(void)
252253
* Please see the comment of hash_create() for the nelem value 16 here.
253254
* HASH_BLOBS flag is set because the size of the key is sizeof(uint32).
254255
*/
255-
graph_namespace_cache_hash = hash_create("ag_graph (namespace) cache", 16,
256+
graph_namespace_cache_hash = ShmemInitHash("ag_graph (namespace) cache", 16, 1000,
256257
&hash_ctl,
257258
HASH_ELEM | HASH_BLOBS);
258259
}
@@ -515,8 +516,8 @@ static void create_label_name_graph_cache(void)
515516
* Please see the comment of hash_create() for the nelem value 16 here.
516517
* HASH_BLOBS flag is set because the key for this hash is fixed-size.
517518
*/
518-
label_name_graph_cache_hash = hash_create("ag_label (name, graph) cache",
519-
16, &hash_ctl,
519+
label_name_graph_cache_hash = ShmemInitHash("ag_label (name, graph) cache",
520+
16, 1000, &hash_ctl,
520521
HASH_ELEM | HASH_BLOBS);
521522
}
522523

@@ -532,7 +533,7 @@ static void create_label_graph_oid_cache(void)
532533
* Please see the comment of hash_create() for the nelem value 16 here.
533534
* HASH_BLOBS flag is set because the key for this hash is fixed-size.
534535
*/
535-
label_graph_oid_cache_hash = hash_create("ag_label (graph, id) cache", 16,
536+
label_graph_oid_cache_hash = ShmemInitHash("ag_label (graph, id) cache", 16, 1000,
536537
&hash_ctl,
537538
HASH_ELEM | HASH_BLOBS);
538539
}
@@ -549,7 +550,7 @@ static void create_label_relation_cache(void)
549550
* Please see the comment of hash_create() for the nelem value 16 here.
550551
* HASH_BLOBS flag is set because the size of the key is sizeof(uint32).
551552
*/
552-
label_relation_cache_hash = hash_create("ag_label (relation) cache", 16,
553+
label_relation_cache_hash = ShmemInitHash("ag_label (relation) cache", 16, 1000,
553554
&hash_ctl, HASH_ELEM | HASH_BLOBS);
554555
}
555556

0 commit comments

Comments
 (0)