PLAN SQL STMT

PLAN SQL STMT mk Fri, 12/26/2014 - 13:59

The relational plan used in the SQL optimizer can be obtained by prepending the query with the keyword PLAN.

sql>plan select count(*) from tables;
+--------------------------------------------------------------------------------------+
| rel                                                                                  |
+======================================================================================+
| project (                                                                            |
| | group by (                                                                         |
| | | union (                                                                          |
| | | | group by (                                                                     |
| | | | | project (                                                                    |
| | | | | | select (                                                                   |
| | | | | | | table(sys._tables) [ _tables.id as p.id, _tables.type as p.type ] COUNT  |
| | | | | | ) [ p.type != smallint[tinyint "2"] ]                                      |
| | | | | ) [ p.id as tables.id ]                                                      |
| | | | ) [  ] [ sys.count() NOT NULL as L1.L1 ],                                      |
| | | | group by (                                                                     |
| | | | | project (                                                                    |
| | | | | | select (                                                                   |
| | | | | | | table(tmp._tables) [ _tables.id as t.id, _tables.type as t.type ] COUNT  |
| | | | | | ) [ t.type != smallint[tinyint "2"] ]                                      |
| | | | | ) [ t.id as tables.id ]                                                      |
| | | | ) [  ] [ sys.count() NOT NULL as L1.L1 ]                                       |
| | | ) [ L1.L1 ]                                                                      |
| | ) [  ] [ sys.sum no nil (L1.L1) as L1.L1 ]                                         |
| ) [ L1 NOT NULL as L1.L1 ]                                                           |
+--------------------------------------------------------------------------------------+