Hi,

I'm a Computer Science student and I'm currently studying databases buffer
managers.  I want to do some experiments and see how the pages access works
in PostgreSQL. (and I also will do some I/O experiments)

So, I want to do a "sniffer" on the Storage Layer of Postgresql. It should
work telling me the page that PGSQL is reading or writing. So when I make
some operation on PGSQL, the pages that were requested (to read or write) by
PGSQL for the buffer, are stored in a separated file. And after that i can
build some graphs, conclusions, etc...

So, I made such a code to do that, but i'm not quite sure if I'm doing the
right thing. Can someone of you give me a opinion ??

Many Thanks in advance,
Jonas Jeske

The modified code is in bufmgr.c of PostgreSQL source code.

Buffer
ReadBuffer(Relation reln, BlockNumber blockNum)
{
    volatile BufferDesc *bufHdr;
    Block        bufBlock;
    bool        found;
    bool        isExtend;
    bool        isLocalBuf;

    /*jjeske starts here */
    FILE *fp;
    fp = fopen("/home/jjeske/tpccuva/pgsql/saida.txt","a");
    fprintf(fp,"Read Block n: %d\n",(int) blockNum);
    fclose(fp);

....

static void
write_buffer(Buffer buffer, bool unpin)
{
    volatile BufferDesc *bufHdr;

    /*jjeske starts here */
    FILE *fp;
    fp = fopen("/home/jjeske/tpccuva/pgsql/saida.txt","a");
    fprintf(fp,"Write Block n: %d\n",(int) buffer);
    fclose(fp);
....

Reply via email to