pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PQputline in BINARY mode?
4+ messages / 2 participants
[nested] [flat]

* PQputline in BINARY mode?
@ 2002-08-13 21:41  pacquet@newsguy.com
  0 siblings, 1 reply; 4+ messages in thread

From: pacquet@newsguy.com @ 2002-08-13 21:41 UTC (permalink / raw)
  To: pgsql-interfaces

OK, I've tested both a

COPY BINARY <table> FROM <file>

which was very fast, and now I've also done:


PQputline(conn, <test ascii string>)


the question is, can I combine both techniques, and use a programmatic
interface to copy binary information?  We have an data collection application
which needs to insert a huge amount of (binary) information very quickly, so
I'm interested in squeezing out every last CPU cycle.  (any other tips you
have will also be appreciated).  Thanks




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: PQputline in BINARY mode?
@ 2002-08-13 21:53  Tom Lane <tgl@sss.pgh.pa.us>
  parent: pacquet@newsguy.com
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2002-08-13 21:53 UTC (permalink / raw)
  To: pacquet@newsguy.com; +Cc: pgsql-interfaces

pacquet@newsguy.com writes:
> the question is, can I combine both techniques, and use a programmatic
> interface to copy binary information?

Nope.  There's no support for binary COPY in the frontend/backend
protocol.  This is one of the things I'd like to see fixed next time
we change the protocol.  (That's a sufficiently painful thing that we
don't do it often --- the last time was release 6.4 --- but we're
considering a protocol rev for the next development cycle, 7.4.)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: PQputline in BINARY mode?
@ 2002-08-13 22:15  pacquet@newsguy.com
  0 siblings, 1 reply; 4+ messages in thread

From: pacquet@newsguy.com @ 2002-08-13 22:15 UTC (permalink / raw)
  To: tgl@sss.pgh.pa.us; pgsql-interfaces

Thanks.  Now I realize what should have been obvious:  the command "COPY
BINARY" is being executed by the backend, while PQputline() is a frontend
routine. Duh.

However, this is an embedded system, so some modest amount of backend-hacking
is quite acceptable if the payoff is large enough. Do you have any pointers on
implementing a variant of COPY BINARY <> FROM file that works out of memory
instead of a file?



At Tue, 13 Aug 2002 17:53:44 -0400, you wrote
>pacquet@newsguy.com writes:
>> the question is, can I combine both techniques, and use a programmatic
>> interface to copy binary information?
>
>Nope.  There's no support for binary COPY in the frontend/backend
>protocol.  This is one of the things I'd like to see fixed next time
>we change the protocol.  (That's a sufficiently painful thing that we
>don't do it often --- the last time was release 6.4 --- but we're
>considering a protocol rev for the next development cycle, 7.4.)
>
>			regards, tom lane
>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: PQputline in BINARY mode?
@ 2002-08-13 22:41  Tom Lane <tgl@sss.pgh.pa.us>
  parent: pacquet@newsguy.com
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2002-08-13 22:41 UTC (permalink / raw)
  To: pacquet@newsguy.com; +Cc: pgsql-interfaces

pacquet@newsguy.com writes:
> However, this is an embedded system, so some modest amount of
> backend-hacking is quite acceptable if the payoff is large enough. Do
> you have any pointers on implementing a variant of COPY BINARY <> FROM
> file that works out of memory instead of a file?

I think what you want is to hack the fe/be protocol so you can pass
binary data in the COPY from stdin/to stdout datastream.  The problem is
that the message protocol for COPY is ASCII strings (ugh).  Change it to
be counted strings and away you go.  (There are more changes that I want
to see in this area than that, but that should get you the functionality
you want...)  backend/commands/copy.c and PQgetline/PQputline on the
frontend side are the things to look at.  Also read the SGML docs'
chapter about the fe/be protocol.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-08-13 22:41 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-13 21:41 PQputline in BINARY mode? pacquet@newsguy.com
2002-08-13 21:53 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-08-13 22:15 Re: PQputline in BINARY mode? pacquet@newsguy.com
2002-08-13 22:41 ` Tom Lane <tgl@sss.pgh.pa.us>

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