Re: ResultSet memory usage - Mailing list pgsql-jdbc

From Timo Savola
Subject Re: ResultSet memory usage
Date
Msg-id 1010784338.10336.15.camel@vorlon
Whole thread Raw
In response to Re: ResultSet memory usage  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
List pgsql-jdbc
> Hmm, PostgreSQL has a non-SQL-standard extension: 'distinct on (expr)':
> I think it might do exactly what you want (n.b. I haven't been following
> this whole thread, just say this comment)
>
> test=# select distinct on (inst) inst, lastname from people
>        order by inst, lastname limit 3;

I need to order by a column other than the unique one (inst), so this
approach doesn't really help me. However, I managed to accomplish the
right ordering and the usage of limit like this:

    select * from people
    where id in
        (select distinct on (inst) id from people order by inst, age)
    order by age
    limit 10;

This is much slower than my original approach: "select * from people
order by age" and then filter out all duplicates afterwards. But it
should help with memory shortages on the client side.

Timo



pgsql-jdbc by date:

Previous
From: "Dave Cramer"
Date:
Subject: Re: Postgres to Java type mapping
Next
From: "Ivan Manuel Andrade Muñoz"
Date:
Subject: Error when executing example esql.xml in Cocoon1.8.2 uses postgresql