Explain plan shows incorrect rows even after collecting 100% statistics
Hi Team,
I have a single node Vertica cluster (VM). When I run the explain on the following query I was getting the Rows read as 127, but the actual records retrieved is 861. Could you advice why I'm not able to match the actual records retrieved in the query results with the explain plan output?
Query:
explain select * from online_sales.online_sales_fact where sale_date_key = 164 and ship_date_key = 165 ;
QUERY PLAN DESCRIPTION:
explain select * from online_sales.online_sales_fact where sale_date_key = 164 and ship_date_key = 165
Access Path:
+-STORAGE ACCESS for online_sales_fact [Cost: 140K, Rows: 127] (PATH ID: 1)
| Projection: online_sales.online_sales_fact_super
| Materialize: online_sales_fact.ship_date_key, online_sales_fact.promotion_key, online_sales_fact.warehouse_key, online_sales_fact.shipping_key, online_sales_fact.online_page_key, online_sales_fact.call_center_key, online_sales_fact.customer_key, online_sales_fact.product_key, online_sales_fact.product_version, online_sales_fact.sale_date_key, online_sales_fact.pos_transaction_number, online_sales_fact.sales_quantity, online_sales_fact.sales_dollar_amount, online_sales_fact.ship_dollar_amount, online_sales_fact.net_dollar_amount, online_sales_fact.cost_dollar_amount, online_sales_fact.gross_profit_dollar_amount, online_sales_fact.transaction_type
| Filter: (online_sales_fact.sale_date_key = 164)
| Filter: (online_sales_fact.ship_date_key = 165)
Comments
The ROWS in an explain plan are the estimated output rows for each operator. In this case (storage access). An EXPLAIN command doesn't run the query. That's why you only get estimates.
Example:
You can profile a query to get an actual row count. When you PROFILE a SQL statement, Vertica runs it.