pre-loading a user table.

Поиск
Список
Период
Сортировка
Искать

pre-loading a user table.

От:
Ana Cerejo <ana.cerejo@yale.edu>
Дата:


I am trying a pre-load a user table during InitPostgres.  I tried to mimic 
the relevant actions in ReverifyDatabase to carry this out.  I manage to 
load the first block of the table.  However, if a table is more than 1 
block, I end up getting warnings about relcache reference leaks. It looks 
like I need to increase the size of the relcache.  Can anyone comment on 
the approach and/or give me any advanced warnings about messing with the 
relcache?

Thanks!


Code follows:

/*** APC 4/1/04* */static void
PreLoadUserTable(Oid relationId)
{Relation	pgdbrel;HeapScanDesc 	pgtblscan;HeapTuple	tup;int i;fprintf(stdout, "APC: PreLoadTable for relation(%d).\n", 	relationId);
//	pgdbrel = heap_open(relationId, AccessShareLock);
/* APC  numKeys seems to be 0 for user tables *//* pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key); */pgtblscan = heap_beginscan(pgdbrel, SnapshotNow, 0, NULL);
fprintf(stdout, "APC: the number of blocks (%d)\n", 	pgtblscan->rs_rd->rd_nblocks);/* XXX how to really load all the blocks, this approach is wrong */for (i=0; i<=irs_rd->rd_nblocks; i++) {	fprintf(stdout, "APC: the number of blocks (%d) for 	round(%d)\n", pgtblscan->rs_rd->rd_nblocks, i);		tup = heap_getnext(pgtblscan, ForwardScanDirection);			if (!HeapTupleIsValid(tup))	{		/* OOPS */		heap_close(pgdbrel, AccessShareLock);
		/* ereport.... */		fprintf(stderr, "APC: FATAL ERROR unable to load 		the table during round(%d).\n", i);	}}heap_endscan(pgtblscan);heap_close(pgdbrel, AccessShareLock);
fprintf(stdout, "APC: PreLoadTable finished for relation(%d).\n", relationId);

} 


Re: pre-loading a user table.

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Ana Cerejo  writes:
> I am trying a pre-load a user table during InitPostgres.  I tried to mimic 
> the relevant actions in ReverifyDatabase to carry this out.  I manage to 
> load the first block of the table.  However, if a table is more than 1 
> block, I end up getting warnings about relcache reference leaks. It looks 
> like I need to increase the size of the relcache.  Can anyone comment on 
> the approach and/or give me any advanced warnings about messing with the 
> relcache?

You've broken something and you haven't got the foggiest idea what :-(
... but "increasing the size of the relcache" definitely isn't the
solution, because it isn't fixed-size.

Why do you think it useful to preload something during InitPostgres,
anyway?  Any heavily used table will certainly be present in shared
buffers already, and even more surely present in kernel buffers.
		regards, tom lane

Re: pre-loading a user table.

От:
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>
Дата:

> Why do you think it useful to preload something during InitPostgres,
> anyway?  Any heavily used table will certainly be present in shared
> buffers already, and even more surely present in kernel buffers.

And if you really want it preloaded you can issue dummy selects
with a client right after startup. I really think locking a table into 
memory is a worthless feature if a good buffer manager is at work.

Andreas

FAQ