Re: query optimisation

Поиск
Список
Период
Сортировка
Искать
От
Mike Mascari
Тема
Re: query optimisation
Дата
Msg-id
3E727F60.9090506@mascari.com
Ответ на
query optimisation (Abdul-wahid Paterson)
Список
Дерево обсуждения
query optimisation Abdul-wahid Paterson <aw@lintrix.net>
Re: query optimisation Tom Lane <tgl@sss.pgh.pa.us>
Re: query optimisation Mike Mascari <mascarm@mascari.com>
Abdul-wahid Paterson wrote:
> Hi,
> 
> I have a query of the form:
> 
> select a.id, e.id from tablea a, tableb b, tablec c, tabled d, tablee e
> where a.fk=b.id and b.fk=c.id and c.fk=d.id and d.fk=e.id;
> 
> In fact, my statement is a bit more complex as it is joined across 7
> tables, has an aggregate function and a CASE statement.
> 
> My problem is that it executes to slow and I need to optimise it. Is
> there any documentation anywhere that can help me work out how to
> optimise the statement? My statement has a few other conditions that
> need to be met on the joining tables. Does changing the order of the
> conditional statement affect the way the statement is optimised?

Assuming indexes on the appropriate tables and a recent VACUUM 
ANALYZE, I've found that using explicit joins can reduce 
planning time significantly:

http://www.postgresql.org/docs/view.php?version=7.2&idoc=0&file=explicit-joins.html

Hope that helps,

Mike Mascari
mascarm@mascari.com



В списке pgsql-general по дате отправления
От: Abdul-wahid Paterson
Дата:
Сообщение: query optimisation
От: Tom Lane
Дата:
Сообщение: Re: query optimisation
FAQ