Re: WIP Join Removal
От | Gregory Stark |
---|---|
Тема | Re: WIP Join Removal |
Дата | |
Msg-id | 87od36u7st.fsf@oxford.xeocode.com обсуждение исходный текст |
Ответ на | Re: WIP Join Removal (Simon Riggs <simon@2ndQuadrant.com>) |
Ответы |
Re: WIP Join Removal
Re: WIP Join Removal Re: WIP Join Removal |
Список | pgsql-patches |
Simon Riggs <simon@2ndQuadrant.com> writes: > Same answer, just slower. Removing the join makes the access to a into a > SeqScan, whereas it was a two-table index plan when both tables present. > The two table plan is added by the immediately preceding call add_... - > i.e. that plan is only added during join time not during planning of > base relations. Perhaps it would clearer to discuss a non-outer join here: select invoices.* from customer join invoices using (company_id,customer_id) where customer_id = ? where there's a foreign key relation guaranteeing that every invoice has a matching <company_id, customer_id>. If there's an index on customer(customer_id) but not on invoices(customer_id) then conceivably it would be faster to use that than scan all of the invoices. I wonder if it would be more worthwhile to remove them and have a subsequent phase where we look for possible joins to *add*. So even if the user writes "select * from invoices where customer_id=?" the planner might be able to discover that it can find those records quicker by scanning customer, finding the matching <company_id,customer_id> and then using an index to look them up in invoices. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!
В списке pgsql-patches по дате отправления: