pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: John T. Dow <john@johntdow.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: refreshRow is slow
Date: Fri, 15 Jan 2010 10:59:00 +1300
Message-ID: <4B4F93A4.4060601@opencloud.com> (raw)
In-Reply-To: <201001141502.o0EF2Ix3083876@web2.nidhog.com>
References: <201001141502.o0EF2Ix3083876@web2.nidhog.com>

John T. Dow wrote:
> I am having no luck getting responses to a question I posted earlier about optimistic locking with multiple rows.
> 
> I'll ask a more targeted question. How do I efficiently refresh a single row in a resultset?
> 
> Suppose I allow users to view multiple records with TYPE_SCROLL_INSENSITIVE, CONCUR_READ_ONLY.
> 
> The user might select one row or 1,000 rows and scroll back and forth at will.
> 
> The user might choose to change one of the rows. I do this with a separate FOR UPDATE query.
> 
> The update query will fetch the current row, which might be different from the row in the original resultset. My programming compares the two rows and can report to the user the differences. After the row has been updated, I need to refresh that row in the result set so that if the user continues to scroll back and forth, it will see the updated information.
> 
> I am using refreshRow. I do setFetchSize(1) first. This works, but sometimes it is very slow. It can take many seconds over a remote connection. Can I fix that? What's going on?

What's your original query?
What's the query that the driver ends up synthesizing when you call 
refreshRow()?
Have you run that query separately under EXPLAIN ANALYZE etc?

Do you have knowledge of the structure of the original query (i.e. are 
you building it yourself, or is it user-supplied?) If you do, have you 
considered running suitable update/refresh query yourself directly? (The 
driver has limited knowledge of your database structure and may not be 
able to produce 'good' queries for update/refresh via the resultset 
interface)

> Note: I don't want to use TYPE_SCROLL_SENSITIVE because it would update the row in the result set silently and I wouldn't be able to tell the user that somebody had changed anything. (Besides, I understand that TYPE_SCROLL_SENSITIVE doesn't work reliably.)

 From memory the driver doesn't implement TYPE_SCROLL_SENSITIVE at all 
(that type of resultset is quite strange..)

-O




view thread (12+ messages)  latest in thread

Message-ID: <4B4F93A4.4060601@opencloud.com>
Permalink:  ../4B4F93A4.4060601@opencloud.com/
Also on:    postgresql.org/message-id/4B4F93A4.4060601@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, john@johntdow.com
  Subject: Re: refreshRow is slow
  In-Reply-To: <4B4F93A4.4060601@opencloud.com>
  References: <201001141502.o0EF2Ix3083876@web2.nidhog.com> <4B4F93A4.4060601@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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