pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: vanzwieten@stcorp.nl
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Array handling in libpq
Date: Tue, 16 Jan 2007 22:46:11 -0500 (EST)
Message-ID: <200701170346.l0H3kBd23330@momjian.us> (raw)
In-Reply-To: <53632.192.87.1.229.1168989191.squirrel@control.prolocation.net>


Condsidering all the processing required by the query, the conversion
and number of bytes sent over the nework really don't affect
performance.

---------------------------------------------------------------------------

Joris van Zwieten wrote:
> Hi everyone,
> 
> 
> I've been using postgres for several projects and I must confess I really
> like it so far. :-) I hope someone on this list could help me out.
> 
> Suppose I have a table defined with:
> CREATE TABLE foo(bar double precision[]);
> 
> My initial guess was that, as postgres supports arrays, there would
> probably also be some support for this in libpq (which I'm using via
> libpqxx by the way).
> 
> However, from what I've been able to find, it seems that if I use the text
> format for parameters / results, I would have to:
> 
> 1. [SEND] Convert the double array on the C(++) side to a '{}' delimited
> string representation.
> 2. [RECV] Convert something like '{3.124, 4.5234, 123.123}' to a C(++)
> array of doubles myself.
> 
> I hope I overlooked something and there is some support for sending /
> receiving (parsing) arrays in libpq?? That would be a big help.
> 
> Still, sending double in ASCII does not seem that efficient. It's not a
> trivial conversion and it takes more bytes than sending it as binary.
> However, it seems that using the binary format, I would have to:
> 
> 1. [SEND] Convert to network byte order
>           Send the array in the format arrayfuncs.c::array_recv() expects,
>           i.e. including the right header (and a length per element as
>           well).
> 2. [RECV] Parse the header, and convert from byte order
> 
> Am I missing something here? Or is this just the way it is? (Which is also
> fine, then at least I know what I'm up against... ;-)
> 
> Thanks,
> 
> Joris van Zwieten
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq

-- 
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +



view thread (8+ messages)  latest in thread

Message-ID: <200701170346.l0H3kBd23330@momjian.us>
Permalink:  ../200701170346.l0H3kBd23330@momjian.us/
Also on:    postgresql.org/message-id/200701170346.l0H3kBd23330@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: bruce@momjian.us, vanzwieten@stcorp.nl
  Subject: Re: Array handling in libpq
  In-Reply-To: <200701170346.l0H3kBd23330@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox