Re: about 7.0 LIMIT optimization

Поиск
Список
Период
Сортировка
От Roberto Cornacchia
Тема Re: about 7.0 LIMIT optimization
Дата
Msg-id C6973EF76FAE3D1178E200807CFD6BF8@rob.c.virgilio.it
обсуждение исходный текст
Ответ на about 7.0 LIMIT optimization  ("Roberto Cornacchia" <rob.c@virgilio.it>)
Список pgsql-hackers
Hi,

> I'm not sure about your comment about referential constraints.  If you
> are doing analysis of restriction clauses to prove that a particular
> stage doesn't require reading as many rows as it otherwise would, then
> you've done more than I have.

Yes, that's what we do. Here is a clarifying example:

-----
"Retrieve name, salary and Dept name of the 10 most paid employees"

SELECT Emp.name, Emp.salary, Dep.nameFROM Emp, Dep
WHERE Emp.dno=Dept.dno
STOP AFTER 10
RANK BY Emp.salary DESC;
-----

Suppose you have a referential constraint like:
Emp->dno --> Dep.dno  (foreign --> primary)

In this case we can do :

join  (Emp.dno = Dep.dno) Stop 10   Scan Emp Scan Dept

since we are sure that every employee works in a departement (because of the constraints), so the 10 most paid
employeeswill survive after the join. In this way you can reduce the cardinality of one of the input stream of the
join,obtaining the same final results. 
 

Note that this is a very simple case. In many plans involving a larger number of joins you can place a Stop operator in
adeep position, reducing the work of all the following joins.
 

We have formalized a set of rules which allow us to determine wheter or not a position in the plan for the Stop
operatoris safe and then we have developed a fast algorithm able to take the right decision.
 

Regards

R. Cornacchia
A. Ghidini
Dr. P. Ciaccia

===========================================================

VIRGILIO MAIL - Il tuo indirizzo E-mail gratis e per sempre
http://mail.virgilio.it/


VIRGILIO - La guida italiana a Internet
http://www.virgilio.it/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Roberto Cornacchia"
Дата:
Сообщение: Re: [HACKERS] Re: about 7.0 LIMIT optimization
Следующее
От: Don Baccus
Дата:
Сообщение: Re: [HACKERS] Re: about 7.0 LIMIT optimization