X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 16F0B9DD5F0 for ; Tue, 6 Dec 2005 18:33:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08217-08 for ; Tue, 6 Dec 2005 18:33:37 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) by postgresql.org (Postfix) with ESMTP id 90FF39DD5E8 for ; Tue, 6 Dec 2005 18:33:33 -0400 (AST) Received: by wproxy.gmail.com with SMTP id i6so502916wra for ; Tue, 06 Dec 2005 14:33:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=POtJsx3RlaLsjeixjZXzVi/WJLpI6N2kALy4nrhurUcU0DQIhw95DC4LsQ8KccBiFKcSJ7AY5UKxIG8rwWE5jhkwFMrtcnM9POyJhwvwXP1jB83tRnDCZf1hG+wEzADopSjKo4E2Dm7wmqxG78XRWHHZRS9PY/Ph4JJnx5U2BEc= Received: by 10.54.109.14 with SMTP id h14mr1143652wrc; Tue, 06 Dec 2005 14:33:35 -0800 (PST) Received: by 10.54.97.3 with HTTP; Tue, 6 Dec 2005 14:33:35 -0800 (PST) Message-ID: <3fccaa690512061433m18153115q6ae607cb9febff8c@mail.gmail.com> Date: Tue, 6 Dec 2005 16:33:35 -0600 From: Andres Olarte To: "pgsql-jdbc@postgresql.org" Subject: Re: Advise on mapping JTable to large PostgreSQL table In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12293_26777532.1133908415895" References: <1133860141.8837.46.camel@Panoramix> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200512/33 X-Sequence-Number: 14364 ------=_Part_12293_26777532.1133908415895 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Couldn't you use a single ugly "SELECT *" with a cursor and then fill your local cache as the client is scrolling through the table? It will scroll kind of slow the first time, but then i'll work nice. I'm not very into Swing, but for that you'd only need the number of rows with something like "SELECT count(*)". On 12/6/05, Kris Jurka wrote: > > > > On Tue, 6 Dec 2005, Joost Kraaijeveld wrote: > > > I *must* (as in: I have no choice and it can't be solved another way by > > customer demand) display a large table (> 1.100.000 records) in a JTabl= e > > ( or something that looks like a JTable for the customer). > > > > AS a JTable works with rows, so I have written code that calculates the > > row of the record in the query and maps any row request to an index in > > the query. > > > > 1. Customer wants the record with 'some text' in column 'a' > > 2. I calculate the index: > > select count(*) from table where a < 'some text' > > There's got to be a better way of storing this index. If this is readonl= y > data then you could easily number all of these in the database itself. I > think the problem may be that you are trying to index all this data as an > array where you need an absolute offset. Perhaps a different data > structure would make a better backing type? > > > 4. If not, I get 100 records before and after the requested record, > > including the record itself and put them in the local cache so that > > JTable can call AbstratTableModel.getValueAt(row,column) without the > > need of accessing the database. > > How do you determine the records before and after at the moment? > > Kris Jurka > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match > ------=_Part_12293_26777532.1133908415895 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Couldn't you use a single ugly "SELECT *" with a cursor and then = fill your local cache as the client is scrolling through the table?  I= t will scroll kind of slow the first time, but then i'll work nice. I'm not= very into Swing, but for that you'd only need the number of rows  wit= h something like "SELECT count(*)". =20

On 12/6/05, = Kris Jurka <books@ejurka.com= > wrote:


On Tue, 6 Dec 2005, Joos= t Kraaijeveld wrote:

> I *must* (as in: I have no choice and it c= an't be solved another way by
> customer demand) display a large table (> 1.100.000 records) in= a JTable
> ( or something that looks like a JTable for the customer)= .
>
> AS a JTable works with rows, so I have written code that = calculates the
> row of the record in the query and maps any row request to an inde= x in
> the query.
>
> 1. Customer wants the record with '= some text' in column 'a'
> 2. I calculate the index:
> select c= ount(*) from table where a < 'some text'

There's got to be a better way of storing this index.  If= this is readonly
data then you could easily number all of these in the = database itself.  I
think the problem may be that you are tryi= ng to index all this data as an
array where you need an absolute offset.  Perhaps a different= data
structure would make a better backing type?

> 4. If not,= I get 100 records before and after the requested record,
> including= the record itself and put them in the local cache so that
> JTable can call AbstratTableModel.getValueAt(row,column) without t= he
> need of accessing the database.

How do you determine the = records before and after at the moment?

Kris Jurka

----------= -----------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to      choose an index scan if your joining c= olumn's datatypes do not
      match

------=_Part_12293_26777532.1133908415895--