pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Query Approach and performance
2+ messages / 2 participants
[nested] [flat]

* Query Approach and performance
@ 2001-08-17 07:29 Morgan Curley <mcurley@e4media.com>
  2001-08-17 09:47 ` Re: Query Approach and performance Martijn van Oosterhout <kleptog@svana.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Morgan Curley @ 2001-08-17 07:29 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

Hey everyone,
On average, are multiple simple queries better performance-wise than joins?
i.e.
select A.col1 from table1 A
select B.col2 from table2 B where B.col1 = A.col1
etc

vs

select A.col1, B.col2 from table1 A, table2 B where B.col1 = A.col1

Are joins better for small/large numbers of tables?
Is there a diff?
My approach to date has been to keep queries as simple as possible, and 
when I see a need for complicated joins, I create a view and then do simple 
queries against that.

Does pg cache queries like Oracle does so that repeated queries don't need 
to go through the compile phase and run faster? Is this configurable?

Thanks,
Morgan




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

* Re: Query Approach and performance
  2001-08-17 07:29 Query Approach and performance Morgan Curley <mcurley@e4media.com>
@ 2001-08-17 09:47 ` Martijn van Oosterhout <kleptog@svana.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Martijn van Oosterhout @ 2001-08-17 09:47 UTC (permalink / raw)
  To: Morgan Curley <mcurley@e4media.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

On Fri, Aug 17, 2001 at 03:29:36AM -0400, Morgan Curley wrote:
> Hey everyone,
> On average, are multiple simple queries better performance-wise than joins?
> i.e.
> select A.col1 from table1 A
> select B.col2 from table2 B where B.col1 = A.col1
> etc
> 
> vs
> 
> select A.col1, B.col2 from table1 A, table2 B where B.col1 = A.col1
> 
> Are joins better for small/large numbers of tables?
> Is there a diff?

Letting the database do joins is always better than doing them yourself.

> My approach to date has been to keep queries as simple as possible, and 
> when I see a need for complicated joins, I create a view and then do simple 
> queries against that.

I don't think it makes that much difference. Views are precompiled to some
extend.

> Does pg cache queries like Oracle does so that repeated queries don't need 
> to go through the compile phase and run faster? Is this configurable?

Hmm, I've never noticed that query compilation actually took any noticable
time. No, postgres doesn't do that but I'm not convinced it would make a
difference.

HTH,
-- 
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> It would be nice if someone came up with a certification system that
> actually separated those who can barely regurgitate what they crammed over
> the last few weeks from those who command secret ninja networking powers.



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


end of thread, other threads:[~2001-08-17 09:47 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-08-17 07:29 Query Approach and performance Morgan Curley <mcurley@e4media.com>
2001-08-17 09:47 ` Martijn van Oosterhout <kleptog@svana.org>

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