Re: ResultSet memory usage

From: Timo Savola <timo(dot)savola(at)codeonline(dot)com>
To: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: ResultSet memory usage
Date: 2002-01-11 21:25:33
Message-ID: 1010784338.10336.15.camel@vorlon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nick Fankhauser 2002-01-11 21:30:22 Re: Error when executing example esql.xml in Cocoon1.8.2 uses postgresql
Previous Message Ivan Manuel Andrade Muñoz 2002-01-11 21:16:39 Error when executing example esql.xml in Cocoon1.8.2 uses postgresql