Re: JDBC compressed stream

From: John R Pierce <pierce(at)hogranch(dot)com>
To: Javier <jgagis(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC compressed stream
Date: 2005-06-17 19:12:45
Message-ID: 42B320AD.5020709@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Javier wrote:
>
> Hi, I'm developing a java client application that uses JDBC to access
> a PostGIS/PostgreSQL database. I'm working with PostgreSQL JDBC driver
> Type 4 (http://jdbc.postgresql.org/) and I need to compress the output
> streamdata from database queries.
>
> The problem can't be resolved making a better WHERE clause, because I
> have to received a great amount of GIS information, and this info can be
> highly compressed. Moreover, this data can't be stored compressed in the
> database, so, an external compressor is needed.
>
> Anybody can explain me if it is possible to compress a JDBC datastream
> ??? Is this a PostgreSQL JDBC driver issue??? or a new function must be
> added to PostgreSQL???
>
> Last question --> Anyone knows any other way to achieve compression
> with other kind of solution???

you could add a C function to the Postgres server engine which provides the
compression on a field by field basis, then have a corresponding Java function
to decompress the results after you recieve them.

You would use this function on a select statement something like...

SELECT field1, fieldcompress(field2) AS field2,
fieldcompress(field3) AS field3 FROM tablename
WHERE ...;

These sorts of user C functions can be added to the database server at runtime,
you compile the C to a .so shared object file (.DLL on Windows), and load it
into the database server with a CREATE FUNCTION statement.
See http://www.postgresql.org/docs/8.0/static/xfunc-c.html for how you develop,
install, and use these sorts of functions.

otherwise, AFAIK, you'd have to design a new compressed data protocol for
pgsql, implement it in the postgres postmaster, and implement it in the jdbc
client library (as well as pgsql.so for the client applications that aren't
written in Java).

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kevin Grittner 2005-06-17 19:41:24 Re: JDBC compressed stream
Previous Message Javier 2005-06-17 16:26:31 JDBC compressed stream