From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | philb(at)vodafone(dot)ie, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query plan for very large number of joins |
Date: | 2005-06-02 16:26:26 |
Message-ID: | 14834.1117729586@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Richard Huxton <dev(at)archonet(dot)com> writes:
> philb(at)vodafone(dot)ie wrote:
>> I am using PostgreSQL (7.4) with a schema that was generated
>> automatically (using hibernate). The schema consists of about 650
>> relations. One particular query (also generated automatically)
>> consists of left joining approximately 350 tables.
> May I be the first to offer an "ouch"!
Seconded.
> However, I'm not sure how much leeway there is in
> planning a largely left-joined query.
Not much. The best hope for a better result is to order the LEFT JOIN
clauses in a way that will produce a good plan.
One thought is that I am not sure I believe the conclusion that planning
is taking only 36 ms; even realizing that the exclusive use of left
joins eliminates options for join order, there are still quite a lot of
plans to consider. You should try both EXPLAIN and EXPLAIN ANALYZE
from psql and see how long each takes. It'd also be interesting to keep
an eye on how large the backend process grows while doing this --- maybe
it's being driven into swap.
Also: I'm not sure there *is* such a thing as a good plan for a 350-way
join. It may be time to reconsider your data representation. If
Hibernate really forces this on you, it may be time to reconsider your
choice of tool.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | J. Andrew Rogers | 2005-06-02 17:10:14 | Re: Adaptec/LSI/?? RAID |
Previous Message | Tom Lane | 2005-06-02 16:10:39 | Re: How to avoid database bloat |