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", "_tables"."type" ] COUNT  |
| | | | | | ) [ "_tables"."type" != smallint "2" ]                           |
| | | | | ) [ "_tables"."id" as "tables"."id" ]                              |
| | | | ) [  ] [ sys.count() NOT NULL as "L41"."L41" ],                      |
| | | | group by (                                                           |
| | | | | project (                                                          |
| | | | | | table(tmp._tables) [ "_tables"."id" ] COUNT                      |
| | | | | ) [ "_tables"."id" as "tables"."id" ]                              |
| | | | ) [  ] [ sys.count() NOT NULL as "L41"."L41" ]                       |
| | | ) [ "L41"."L41" ]                                                      |
| | ) [  ] [ sys.sum no nil ("L41"."L41") as "L41"."L41" ]                   |
| ) [ "L41"."L41" NOT NULL ]                                                 |
+----------------------------------------------------------------------------+
18 tuples
clk: 1.158 ms