Re: Most efficient way for libPQ .. PGresult serialization

From: Joshua Bay <joshuabay93(at)gmail(dot)com>
To: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Most efficient way for libPQ .. PGresult serialization
Date: 2016-08-18 19:08:21
Message-ID: CABb-U3asES1bekhWzMNWUBu+KLzN-pJQVk+RAc2kupcW1BN_zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks,
But I don't think my question was clear enough.

I already managed the connection pooling, and what I need is to serialize
the result.

If PGresult was a contiguous block, I could have just create buffer and
call memcpy for serialization, but structure of result seems much more
complicated.

So, I was asking if there is an easy way to achieve serialization

Thanks!

On Thu, Aug 18, 2016 at 1:33 AM, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> wrote:

> > On 18 August 2016 at 10:05, Joshua Bay <joshuabay93(at)gmail(dot)com> wrote:
> >
> >> Hi,
> >>
> >> I was trying to implement a middleware that lies between client and
> >> postgres.
> >>
> >> So, this middleware is supposed to run query with libpq, do its job on
> >> them, and then serialize the result of query, and send it to the client
> !
> >> (client deserializes to PGresult)
> >>
> >> I could simply iterate over rows and columns but than that would be
> slow.
> >> I also found that query results consist of 3 parts (PGresult, tuples,
> data
> >> blocks).
> >>
> >> Could I please get some pointers ? :)
> >>
> >>
> > Take a look at the code for PgBouncer and PgPool-II. Both implement
> > PostgreSQL protocol proxies you could use as starting points.
>
> This one is based on Pgpool-II.
>
> https://github.com/treasure-data/prestogres
>
> Best regards,
> --
> Tatsuo Ishii
> SRA OSS, Inc. Japan
> English: http://www.sraoss.co.jp/index_en.php
> Japanese:http://www.sraoss.co.jp
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-08-18 19:16:16 Re: Use pread and pwrite instead of lseek + write and read
Previous Message Stefan Kaltenbrunner 2016-08-18 19:08:02 Re: WIP: About CMake v2