Технологии и разработка СУБД
Выполнение запросов
Анастасия Лубенникова
Александр Алексеев
План лекции
Простой запрос
Стадии обработки запроса
Дерево разбора (Parse Tree)
Система правил (RULE)
Path
typedef struct Path� {� NodeTag type;� NodeTag pathtype; /* tag identifying scan/join method */� RelOptInfo *parent; /* the relation this path can build */� PathTarget *pathtarget; /* list of Vars/Exprs, cost, width */� ParamPathInfo *param_info; /* parameterization info, or NULL if none */� � /* estimated size/costs for path (see costsize.c for more info) */� double rows; /* estimated number of result tuples */� Cost startup_cost; /* cost expended before fetching any tuples */� Cost total_cost; /* total cost (assuming all tuples fetched) */� � List *pathkeys; /* sort ordering of path's output */� /* pathkeys is a List of PathKey nodes; see above */� } Path;
Pathlist
Лист сортируется по total_cost, также учитываются startup_cost и rows.
В итоге выбирается оптимальный путь и по нему строится детальный план запроса.
EXPLAIN
EXPLAIN (ANALYZE)
Чем отличаются разные пути?
Методы сканирования
Sequential Scan
Index Scan
Index Only Scan
Bitmap Index Scan
Методы соединения
Nested Loop with Seq Scan
Nested Loop with Index Scan
Hash Join
Merge Join
Порядок соединения
Настройки планировщика (1)
Настройки планировщика (2)
Дополнительные материалы
Вопросы и ответы.