Re: Help with tuning this query

From: "Ken Egervari" <ken(at)upfactor(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Help with tuning this query
Date: 2005-03-02 18:56:57
Message-ID: 002801c51f59$9c043900$6a01a8c0@KEN
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32 pgsql-performance

>> left join is for eager loading so that I don't have to run a seperate
>> query
>> to fetch the children for each shipment. This really does improve
>> performance because otherwise you'll have to make N+1 queries to the
>> database, and that's just too much overhead.
>
> are you saying that you are actually doing a
> select s.*,ss.* ...
> ?

Yes, this is how the SQL should be written. When I manually converted the
query, I forgot to include this detail. In hibernate, you don't need to
specifiy the ss.* because you are dealing with objects, so you just say
shipment. The ss.* is indicated in the "fetch" part of the Hibernate query.
That was my mistake.

> it might help the planner estimate better the number of cs rows
> affected. whether this improves performance depends on whether
> the best plans are sensitive to this.

This sounds like a good idea since cs rows are quite large. shipment and
shipment_status are the largest tables in the database and they will grow
very large over time.

In response to

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Ken Egervari 2005-03-02 20:06:58 Re: Help with tuning this query (with explain analyze finally)
Previous Message Ragnar Hafstað 2005-03-02 18:49:53 Re: Help with tuning this query

Browse pgsql-performance by date

  From Date Subject
Next Message Ken Egervari 2005-03-02 20:06:58 Re: Help with tuning this query (with explain analyze finally)
Previous Message Ragnar Hafstað 2005-03-02 18:49:53 Re: Help with tuning this query