pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
optimization for repeated values within JOINs
2+ messages / 2 participants
[nested] [flat]

* optimization for repeated values within JOINs
@ 2005-02-03 16:08  Bill Schneider <bschneider@vecna.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Bill Schneider @ 2005-02-03 16:08 UTC (permalink / raw)
  To: pgsql-jdbc

Hello,

Does the PostgreSQL JDBC driver/protocol perform any optimization for 
repeated values created by joins?  For example, let's say you have a 
query like

select a.id, a.longText, b.id
   from a join b on b.a_id = a.id
   order by a.id;

In the returned result set, the a.longText value will be duplicated for 
every b that matches the row in a.

Is it possible for the driver to do some kind of optimization to prevent 
pushing the longText value over the network redundantly when it just 
repeats the value from the last row in the result set?

Likewise, since String is immutable, could the JDBC driver use the same 
String instance rather than instantiating a new String when the value 
returned exactly matches the last row?

I guess this isn't about the JDBC driver so much as the underlying 
protocol--you'd need some code to indicate "same as last row" for any 
given column.

Has anyone else thought about this, or does it just not affect 
performance enough to matter?

-- Bill
-- 
Bill Schneider
Chief Architect

Vecna Technologies
5004 Lehigh Rd., Suite B
College Park, MD 20740
bschneider@vecna.com
t: 301-864-7253 x1140
f: 301-699-3180




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: optimization for repeated values within JOINs
@ 2005-02-03 20:52  Oliver Jowett <oliver@opencloud.com>
  parent: Bill Schneider <bschneider@vecna.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliver Jowett @ 2005-02-03 20:52 UTC (permalink / raw)
  To: Bill Schneider <bschneider@vecna.com>; +Cc: pgsql-jdbc

Bill Schneider wrote:

> Does the PostgreSQL JDBC driver/protocol perform any optimization for 
> repeated values created by joins?

No. The existing protocol is documented at 
http://www.postgresql.org/docs/8.0/static/protocol.html

> Has anyone else thought about this, or does it just not affect 
> performance enough to matter?

pgsql-hackers is probably the place to discuss it.

> select a.id, a.longText, b.id
>   from a join b on b.a_id = a.id
>   order by a.id; 

In this case, you could of course turn it into two separate queries when 
you know the characteristics of the query make that a win. It seems like 
a lot of work for marginal benefit to try to do some sort of 
duplicate-elimination automatically in the protocol.

-O



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-02-03 20:52 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-03 16:08 optimization for repeated values within JOINs Bill Schneider <bschneider@vecna.com>
2005-02-03 20:52 ` Oliver Jowett <oliver@opencloud.com>

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