如何正确分析EXPLAIN语句产生的成本

时间:2016-11-17 11:24:06

标签: postgresql

为了分析我的查询,我使用以下语句跟踪它

total costs

产生了下面的输出。关键是:我可以与其他查询比较成本吗?或者我是否必须总结每个节点的所有[ { "Plan": { "Node Type": "Sort", "Startup Cost": 48.47, "Total Cost": 48.97, "Plan Rows": 200, "Plan Width": 16, "Sort Key": ["r.range_start"], "Plans": [ { "Node Type": "Aggregate", "Strategy": "Plain", "Parent Relationship": "InitPlan", "Subplan Name": "CTE times", "Startup Cost": 1.17, "Total Cost": 1.25, "Plan Rows": 1, "Plan Width": 8, "Plans": [ { "Node Type": "Seq Scan", "Parent Relationship": "Outer", "Relation Name": "hst_energy_d", "Alias": "hst_energy_d", "Startup Cost": 0.00, "Total Cost": 1.15, "Plan Rows": 10, "Plan Width": 8, "Filter": "((idinstrum = 4) AND (id_device = 122))" } ] }, { "Node Type": "CTE Scan", "Parent Relationship": "InitPlan", "Subplan Name": "CTE ranges", "CTE Name": "times", "Alias": "times", "Startup Cost": 0.00, "Total Cost": 5.02, "Plan Rows": 1000, "Plan Width": 16 }, { "Node Type": "Seq Scan", "Parent Relationship": "InitPlan", "Subplan Name": "CTE rounded_hst", "Relation Name": "hst_energy_d", "Alias": "hst_energy_d", "Startup Cost": 0.00, "Total Cost": 1.47, "Plan Rows": 10, "Plan Width": 576, "Filter": "((idinstrum = 4) AND (id_device = 122))" }, { "Node Type": "Aggregate", "Strategy": "Hashed", "Parent Relationship": "Outer", "Startup Cost": 29.57, "Total Cost": 33.08, "Plan Rows": 200, "Plan Width": 16, "Plans": [ { "Node Type": "Hash Join", "Parent Relationship": "Outer", "Join Type": "Left", "Startup Cost": 0.33, "Total Cost": 24.57, "Plan Rows": 1000, "Plan Width": 16, "Hash Cond": "(r.range_start = hd.round_time)", "Plans": [ { "Node Type": "CTE Scan", "Parent Relationship": "Outer", "CTE Name": "ranges", "Alias": "r", "Startup Cost": 0.00, "Total Cost": 20.00, "Plan Rows": 1000, "Plan Width": 8 }, { "Node Type": "Hash", "Parent Relationship": "Inner", "Startup Cost": 0.20, "Total Cost": 0.20, "Plan Rows": 10, "Plan Width": 16, "Plans": [ { "Node Type": "CTE Scan", "Parent Relationship": "Outer", "CTE Name": "rounded_hst", "Alias": "hd", "Startup Cost": 0.00, "Total Cost": 0.20, "Plan Rows": 10, "Plan Width": 16 } ] } ] } ] } ] } } ]

<input data-val="true" data-val-required="*" id="Password" name="Password" type="password" class="k-textbox" />

0 个答案:

没有答案