相同的代码和表分区提供的执行时间大大不同(2-4秒对4-5分钟),我遇到了问题。
我有一个查询要花很长时间才能运行,因此我决定创建一个循环以按顺序运行它。该查询从两个大型分区表中联接数据,但是某些分区需要2-4秒才能运行,而其他分区则需要5分钟左右的时间。似乎较大的分区实际上是运行速度更快的分区。
当我检查快速查询和慢速查询之间的执行计划时,它们是完全不同的,并且我不明白为什么-基础分区相同并且查询相同-我所更改的只是一个参数,下面的示例代码中的示例从ratio_id 1到ratio_id 7:
SELECT tco.security_id, rr.period_id,rr.classificationtype_id,rr.cat, rr.composite_id, unnest(array[1,2,3,4]) as ord,
unnest(array[case when score_id in (4,5,6) then rr.cat when score_id in (1,2,3) then 12-rr.cat end::text,(rr.pct_of_companies::numeric(4,3))::text ,
case when numrange( case when rr.cat=1 then NULL else reasonable_range_min+(rr.cat-2)*(reasonable_range_max-reasonable_range_min)/9 end,
case when rr.cat=11 then NULL else reasonable_range_min+(rr.cat-1)*(reasonable_range_max-reasonable_range_min)/9 end)@>v.ratiovalue::NUMERIC
then 'stroke-color: #000000; stroke-width: 2; fill-color: ' else '' end||case when score_id in (4,5,6) then t_clr.hexclr when score_id in (1,2,3) then t_clr.hexclr_inv else '#ffffff' end::text,
case when numrange( case when rr.cat=1 then NULL else reasonable_range_min+(rr.cat-2)*(reasonable_range_max-reasonable_range_min)/9 end,
case when rr.cat=11 then NULL else reasonable_range_min+(rr.cat-1)*(reasonable_range_max-reasonable_range_min)/9 end)@>v.ratiovalue::NUMERIC
then 'X' else '' end::text ])::text as vcol
,v.ratiovalue, rv.rankvalue
FROM tco
INNER JOIN research.companyratios v on v.company_id=tco.company_id and upper(v.validrangez)='infinity' and v.ratio_id=1
INNER JOIN research.classification cl on cl.company_id = tco.company_id and upper(cl.validrangez)='infinity'
inner join output.neutron_ratiosranges rr on rr.ratio_id=1 and rr.agg_id=1 and v.period_id=rr.period_id and rr.classification_id=cl.classification_id
INNER JOIN settings.ratios r on r.id=1
INNER JOIN research.companyranks rv on rv.company_id=tco.company_id and upper(rv.validrangez)='infinity'
and rv.ratio_id=1 and rv.period_id=rr.period_id
and rv.classificationtype_id=rr.classificationtype_id
INNER JOIN t_clr on rv.rankvalue::integer<@t_clr.scorerng
这是执行缓慢的计划:
[{"Plan": {"Startup Cost": 2919.19,"Plans": [{"Startup Cost": 2919.19,"Plans": [{"Startup Cost": 2919.04,"Plans": [{"Startup Cost": 2919.04,"Plans": [{"Hash Cond": "((rr.period_id = rv.period_id) AND (rr.classificationtype_id = rv.classificationtype_id))","Startup Cost": 2918.76,"Plans": [{"Startup Cost": 5.75,"Plan Width": 22,"Plans": [{"Startup Cost": 0,"Plan Width": 0,"Node Type": "Bitmap Index Scan","Index Cond": "((rr.agg_id = 1) AND (rr.ratio_id = 7))","Plan Rows": 143,"Parallel Aware": false,"Parent Relationship": "Outer","Total Cost": 5.72,"Index Name": "neutron_ratiosranges_agg_id_ratio_id_period_id_classification_i"}],"Recheck Cond": "((rr.agg_id = 1) AND (rr.ratio_id = 7))","Node Type": "Bitmap Heap Scan","Plan Rows": 143,"Relation Name": "neutron_ratiosranges","Alias": "rr","Parallel Aware": false,"Output": ["rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rr.classification_id"],"Parent Relationship": "Outer","Total Cost": 238.53,"Schema": "output"},{"Startup Cost": 2906.51,"Plans": [{"Hash Cond": "(rv.company_id = tco.company_id)","Startup Cost": 80.54,"Plans": [{"Startup Cost": 0,"Plans": [{"Filter": "((rv.ratio_id = 7) AND (upper(rv.validrangez) = 'infinity'::timestamp with time zone))","Startup Cost": 0,"Plan Width": 10,"Node Type": "Seq Scan","Plan Rows": 1,"Relation Name": "companyranks","Alias": "rv","Parallel Aware": false,"Output": ["rv.rankvalue","rv.company_id","rv.period_id","rv.classificationtype_id"],"Parent Relationship": "Member","Total Cost": 0,"Schema": "research"},{"Filter": "(rv_1.ratio_id = 7)","Startup Cost": 35.96,"Plan Width": 10,"Plans": [{"Startup Cost": 0,"Plan Width": 0,"Node Type": "Bitmap Index Scan","Plan Rows": 700,"Parallel Aware": false,"Parent Relationship": "Outer","Total Cost": 35.78,"Index Name": "companyranks_partial_inf_7_1_idx"}],"Recheck Cond": "(upper(rv_1.validrangez) = 'infinity'::timestamp with time zone)","Node Type": "Bitmap Heap Scan","Plan Rows": 700,"Relation Name": "zpart_companyranks_7_1","Alias": "rv_1","Parallel Aware": false,"Output": ["rv_1.rankvalue","rv_1.company_id","rv_1.period_id","rv_1.classificationtype_id"],"Parent Relationship": "Member","Total Cost": 1251.24,"Schema": "research"},{"Filter": "(rv_2.ratio_id = 7)","Startup Cost": 27.64,"Plan Width": 10,"Plans": [{"Startup Cost": 0,"Plan Width": 0,"Node Type": "Bitmap Index Scan","Plan Rows": 640,"Parallel Aware": false,"Parent Relationship": "Outer","Total Cost": 27.48,"Index Name": "companyranks_partial_inf_7_2_idx"}],"Recheck Cond": "(upper(rv_2.validrangez) = 'infinity'::timestamp with time zone)","Node Type": "Bitmap Heap Scan","Plan Rows": 640,"Relation Name": "zpart_companyranks_7_2","Alias": "rv_2","Parallel Aware": false,"Output": ["rv_2.rankvalue","rv_2.company_id","rv_2.period_id","rv_2.classificationtype_id"],"Parent Relationship": "Member","Total Cost": 1152.65,"Schema": "research"},{"Filter": "(rv_3.ratio_id = 7)","Startup Cost": 9.46,"Plan Width": 10,"Plans": [{"Startup Cost": 0,"Plan Width": 0,"Node Type": "Bitmap Index Scan","Plan Rows": 223,"Parallel Aware": false,"Parent Relationship": "Outer","Total Cost": 9.4,"Index Name": "companyranks_partial_inf_7_7_idx"}],"Recheck Cond": "(upper(rv_3.validrangez) = 'infinity'::timestamp with time zone)","Node Type": "Bitmap Heap Scan","Plan Rows": 223,"Relation Name": "zpart_companyranks_7_7","Alias": "rv_3","Parallel Aware": false,"Output": ["rv_3.rankvalue","rv_3.company_id","rv_3.period_id","rv_3.classificationtype_id"],"Parent Relationship": "Member","Total Cost": 411.89,"Schema": "research"}],"Node Type": "Append","Plan Rows": 1564,"Parallel Aware": false,"Parent Relationship": "Outer","Plan Width": 10,"Total Cost": 2815.78},{"Startup Cost": 60.24,"Plans": [{"Startup Cost": 0,"Plan Width": 8,"Node Type": "Seq Scan","Plan Rows": 1624,"Relation Name": "tco","Alias": "tco","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id"],"Parent Relationship": "Outer","Total Cost": 60.24,"Schema": "pg_temp_5"}],"Node Type": "Hash","Plan Rows": 1624,"Parallel Aware": false,"Output": ["tco.security_id","tco.company_id"],"Parent Relationship": "Inner","Plan Width": 8,"Total Cost": 60.24}],"Node Type": "Hash Join","Plan Rows": 433,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","rv.rankvalue","rv.company_id","rv.period_id","rv.classificationtype_id"],"Parent Relationship": "Outer","Plan Width": 18,"Total Cost": 2906.51}],"Node Type": "Hash","Plan Rows": 433,"Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","rv.rankvalue","rv.company_id","rv.period_id","rv.classificationtype_id"],"Parent Relationship": "Inner","Plan Width": 18,"Total Cost": 2906.51}],"Node Type": "Hash Join","Plan Rows": 140,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","rv.rankvalue","rv.company_id","rv.period_id","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rr.classification_id"],"Parent Relationship": "Outer","Plan Width": 38,"Total Cost": 3191.91},{"Index Cond": "(cl.company_id = tco.company_id)","Startup Cost": 0.28,"Scan Direction": "NoMovement","Plan Width": 8,"Node Type": "Index Only Scan","Total Cost": 4.03,"Plan Rows": 1,"Relation Name": "classification","Alias": "cl","Parallel Aware": false,"Filter": "(upper(cl.validrangez) = 'infinity'::timestamp with time zone)","Output": ["cl.classification_id","cl.company_id","cl.validrangez"],"Parent Relationship": "Inner","Schema": "research","Index Name": "unique_classification_daterange_research"}],"Node Type": "Nested Loop","Plan Rows": 1,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","cl.company_id","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rv.rankvalue","rv.company_id","rv.period_id"],"Parent Relationship": "Outer","Plan Width": 38,"Join Filter": "(rr.classification_id = cl.classification_id)","Total Cost": 3757.99},{"Startup Cost": 0,"Plans": [{"Filter": "((v.ratio_id = 7) AND (tco.company_id = v.company_id) AND (upper(v.validrangez) = 'infinity'::timestamp with time zone))","Startup Cost": 0,"Plan Width": 24,"Node Type": "Seq Scan","Plan Rows": 1,"Relation Name": "companyratios","Alias": "v","Parallel Aware": false,"Output": ["v.ratiovalue","v.company_id","v.period_id"],"Parent Relationship": "Member","Total Cost": 0,"Schema": "research"},{"Index Cond": "(v_1.company_id = tco.company_id)","Startup Cost": 0.29,"Scan Direction": "Forward","Plan Width": 11,"Node Type": "Index Scan","Total Cost": 7.39,"Plan Rows": 1,"Relation Name": "zpart_companyratios_7","Alias": "v_1","Parallel Aware": false,"Filter": "(v_1.ratio_id = 7)","Output": ["v_1.ratiovalue","v_1.company_id","v_1.period_id"],"Parent Relationship": "Member","Schema": "research","Index Name": "companyratios_partial_inf_7_idx"}],"Node Type": "Append","Plan Rows": 2,"Parallel Aware": false,"Parent Relationship": "Inner","Plan Width": 11,"Total Cost": 7.39}],"Node Type": "Nested Loop","Plan Rows": 1,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","v.ratiovalue","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rv.rankvalue"],"Parent Relationship": "Outer","Plan Width": 29,"Join Filter": "(rr.period_id = v.period_id)","Total Cost": 3765.41},{"Index Cond": "(r.id = 7)","Startup Cost": 0.14,"Scan Direction": "Forward","Plan Width": 8,"Node Type": "Index Scan","Total Cost": 8.16,"Plan Rows": 1,"Relation Name": "ratios","Alias": "r","Parallel Aware": false,"Output": ["r.reasonable_range_min","r.reasonable_range_max"],"Parent Relationship": "Inner","Schema": "settings","Index Name": "ratios_primarykey"}],"Node Type": "Nested Loop","Plan Rows": 1,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","v.ratiovalue","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","r.reasonable_range_min","r.reasonable_range_max","rv.rankvalue"],"Parent Relationship": "Outer","Plan Width": 37,"Total Cost": 3773.58},{"Startup Cost": 0,"Plan Width": 96,"Node Type": "Seq Scan","Plan Rows": 650,"Relation Name": "t_clr","Alias": "t_clr","Parallel Aware": false,"Output": ["t_clr.scorerng","t_clr.hexclr","t_clr.hexclr_inv"],"Parent Relationship": "Inner","Total Cost": 16.5,"Schema": "pg_temp_5"}],"Node Type": "Nested Loop","Plan Rows": 100,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","unnest('{1,2,3,4}'::integer[])","unnest(ARRAY[(CASE WHEN (rr.score_id = ANY ('{4,5,6}'::integer[])) THEN (rr.cat)::integer WHEN (rr.score_id = ANY ('{1,2,3}'::integer[])) THEN (12 - rr.cat) ELSE NULL::integer END)::text, ((rr.pct_of_companies)::numeric(4,3))::text, (CASE WHEN (numrange(CASE WHEN (rr.cat = 1) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 2))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END, CASE WHEN (rr.cat = 11) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 1))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END) @> v.ratiovalue) THEN 'stroke-color: #000000; stroke-width: 2; fill-color: '::text ELSE ''::text END || CASE WHEN (rr.score_id = ANY ('{4,5,6}'::integer[])) THEN t_clr.hexclr WHEN (rr.score_id = ANY ('{1,2,3}'::integer[])) THEN t_clr.hexclr_inv ELSE '#ffffff'::text END), CASE WHEN (numrange(CASE WHEN (rr.cat = 1) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 2))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END, CASE WHEN (rr.cat = 11) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 1))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END) @> v.ratiovalue) THEN 'X'::text ELSE ''::text END])","v.ratiovalue","rv.rankvalue"],"Plan Width": 55,"Join Filter": "((rv.rankvalue)::integer <@ t_clr.scorerng)","Total Cost": 3800.45}}]
这是最快的方法:
[{"Plan": {"Startup Cost": 377.98,"Plans": [{"Startup Cost": 377.98,"Plans": [{"Startup Cost": 377.84,"Plans": [{"Hash Cond": "((rv.period_id = rr.period_id) AND (cl.classification_id = rr.classification_id) AND (rv.classificationtype_id = rr.classificationtype_id))","Startup Cost": 377.84,"Plans": [{"Startup Cost": 80.54,"Plans": [{"Hash Cond": "(cl.company_id = tco.company_id)","Startup Cost": 80.54,"Plans": [{"Filter": "(upper(cl.validrangez) = 'infinity'::timestamp with time zone)","Startup Cost": 0,"Plan Width": 8,"Node Type": "Seq Scan","Plan Rows": 825,"Relation Name": "classification","Alias": "cl","Parallel Aware": false,"Output": ["cl.company_id","cl.classification_id","cl.pctexposure","cl.validrangez"],"Parent Relationship": "Outer","Total Cost": 4279.74,"Schema": "research"},{"Startup Cost": 60.24,"Plans": [{"Startup Cost": 0,"Plan Width": 8,"Node Type": "Seq Scan","Plan Rows": 1624,"Relation Name": "tco","Alias": "tco","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id"],"Parent Relationship": "Outer","Total Cost": 60.24,"Schema": "pg_temp_4"}],"Node Type": "Hash","Plan Rows": 1624,"Parallel Aware": false,"Output": ["tco.security_id","tco.company_id"],"Parent Relationship": "Inner","Plan Width": 8,"Total Cost": 60.24}],"Node Type": "Hash Join","Plan Rows": 114,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","cl.company_id","cl.classification_id"],"Parent Relationship": "Outer","Plan Width": 16,"Total Cost": 4364.51},{"Startup Cost": 0,"Plans": [{"Filter": "((rv.ratio_id = 1) AND (tco.company_id = rv.company_id) AND (upper(rv.validrangez) = 'infinity'::timestamp with time zone))","Startup Cost": 0,"Plan Width": 10,"Node Type": "Seq Scan","Plan Rows": 1,"Relation Name": "companyranks","Alias": "rv","Parallel Aware": false,"Output": ["rv.rankvalue","rv.company_id","rv.period_id","rv.classificationtype_id"],"Parent Relationship": "Member","Total Cost": 0,"Schema": "research"},{"Index Cond": "(rv_1.company_id = tco.company_id)","Startup Cost": 0.29,"Scan Direction": "Forward","Plan Width": 10,"Node Type": "Index Scan","Total Cost": 7.09,"Plan Rows": 1,"Relation Name": "zpart_companyranks_1_1","Alias": "rv_1","Parallel Aware": false,"Filter": "(rv_1.ratio_id = 1)","Output": ["rv_1.rankvalue","rv_1.company_id","rv_1.period_id","rv_1.classificationtype_id"],"Parent Relationship": "Member","Schema": "research","Index Name": "companyranks_partial_inf_1_1_idx"},{"Index Cond": "(rv_2.company_id = tco.company_id)","Startup Cost": 0.29,"Scan Direction": "Forward","Plan Width": 10,"Node Type": "Index Scan","Total Cost": 7.09,"Plan Rows": 1,"Relation Name": "zpart_companyranks_1_2","Alias": "rv_2","Parallel Aware": false,"Filter": "(rv_2.ratio_id = 1)","Output": ["rv_2.rankvalue","rv_2.company_id","rv_2.period_id","rv_2.classificationtype_id"],"Parent Relationship": "Member","Schema": "research","Index Name": "companyranks_partial_inf_1_2_idx"},{"Index Cond": "(rv_3.company_id = tco.company_id)","Startup Cost": 0.29,"Scan Direction": "Forward","Plan Width": 10,"Node Type": "Index Scan","Total Cost": 7,"Plan Rows": 1,"Relation Name": "zpart_companyranks_1_7","Alias": "rv_3","Parallel Aware": false,"Filter": "(rv_3.ratio_id = 1)","Output": ["rv_3.rankvalue","rv_3.company_id","rv_3.period_id","rv_3.classificationtype_id"],"Parent Relationship": "Member","Schema": "research","Index Name": "companyranks_partial_inf_1_7_idx"}],"Node Type": "Append","Plan Rows": 4,"Parallel Aware": false,"Parent Relationship": "Inner","Plan Width": 10,"Total Cost": 21.18}],"Node Type": "Nested Loop","Plan Rows": 75,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","cl.company_id","cl.classification_id","rv.rankvalue","rv.company_id","rv.period_id","rv.classificationtype_id"],"Parent Relationship": "Outer","Plan Width": 26,"Total Cost": 6783.98},{"Startup Cost": 292.27,"Plans": [{"Startup Cost": 11.23,"Plan Width": 22,"Plans": [{"Startup Cost": 0,"Plan Width": 0,"Node Type": "Bitmap Index Scan","Index Cond": "((rr.agg_id = 1) AND (rr.ratio_id = 1))","Plan Rows": 287,"Parallel Aware": false,"Parent Relationship": "Outer","Total Cost": 11.16,"Index Name": "neutron_ratiosranges_agg_id_ratio_id_period_id_classification_i"}],"Recheck Cond": "((rr.agg_id = 1) AND (rr.ratio_id = 1))","Node Type": "Bitmap Heap Scan","Plan Rows": 287,"Relation Name": "neutron_ratiosranges","Alias": "rr","Parallel Aware": false,"Output": ["rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rr.classification_id"],"Parent Relationship": "Outer","Total Cost": 292.27,"Schema": "output"}],"Node Type": "Hash","Plan Rows": 287,"Parallel Aware": false,"Output": ["rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rr.classification_id"],"Parent Relationship": "Inner","Plan Width": 22,"Total Cost": 292.27}],"Node Type": "Hash Join","Plan Rows": 1,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","tco.company_id","cl.company_id","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rv.rankvalue","rv.company_id","rv.period_id"],"Parent Relationship": "Outer","Plan Width": 38,"Total Cost": 7162.57},{"Startup Cost": 0,"Plans": [{"Filter": "((v.ratio_id = 1) AND (rv.company_id = v.company_id) AND (rv.period_id = v.period_id) AND (upper(v.validrangez) = 'infinity'::timestamp with time zone))","Startup Cost": 0,"Plan Width": 24,"Node Type": "Seq Scan","Plan Rows": 1,"Relation Name": "companyratios","Alias": "v","Parallel Aware": false,"Output": ["v.ratiovalue","v.company_id","v.period_id"],"Parent Relationship": "Member","Total Cost": 0,"Schema": "research"},{"Index Cond": "(v_1.company_id = rv.company_id)","Startup Cost": 0.42,"Scan Direction": "Forward","Plan Width": 11,"Node Type": "Index Scan","Total Cost": 18.48,"Plan Rows": 1,"Relation Name": "zpart_companyratios_1","Alias": "v_1","Parallel Aware": false,"Filter": "((v_1.ratio_id = 1) AND (rv.period_id = v_1.period_id))","Output": ["v_1.ratiovalue","v_1.company_id","v_1.period_id"],"Parent Relationship": "Member","Schema": "research","Index Name": "companyratios_partial_inf_1_idx"}],"Node Type": "Append","Plan Rows": 2,"Parallel Aware": false,"Parent Relationship": "Inner","Plan Width": 11,"Total Cost": 18.48}],"Node Type": "Nested Loop","Plan Rows": 1,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","v.ratiovalue","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","rv.rankvalue"],"Parent Relationship": "Outer","Plan Width": 29,"Join Filter": "((tco.company_id = v.company_id) AND (rr.period_id = v.period_id))","Total Cost": 7181.08},{"Index Cond": "(r.id = 1)","Startup Cost": 0.14,"Scan Direction": "Forward","Plan Width": 8,"Node Type": "Index Scan","Total Cost": 8.16,"Plan Rows": 1,"Relation Name": "ratios","Alias": "r","Parallel Aware": false,"Output": ["r.reasonable_range_min","r.reasonable_range_max"],"Parent Relationship": "Inner","Schema": "settings","Index Name": "ratios_primarykey"}],"Node Type": "Nested Loop","Plan Rows": 1,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","v.ratiovalue","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","rr.score_id","rr.pct_of_companies","r.reasonable_range_min","r.reasonable_range_max","rv.rankvalue"],"Parent Relationship": "Outer","Plan Width": 37,"Total Cost": 7189.25},{"Startup Cost": 0,"Plan Width": 96,"Node Type": "Seq Scan","Plan Rows": 650,"Relation Name": "t_clr","Alias": "t_clr","Parallel Aware": false,"Output": ["t_clr.scorerng","t_clr.hexclr","t_clr.hexclr_inv"],"Parent Relationship": "Inner","Total Cost": 16.5,"Schema": "pg_temp_4"}],"Node Type": "Nested Loop","Plan Rows": 100,"Join Type": "Inner","Parallel Aware": false,"Output": ["tco.security_id","rr.period_id","rr.classificationtype_id","rr.cat","rr.composite_id","unnest('{1,2,3,4}'::integer[])","unnest(ARRAY[(CASE WHEN (rr.score_id = ANY ('{4,5,6}'::integer[])) THEN (rr.cat)::integer WHEN (rr.score_id = ANY ('{1,2,3}'::integer[])) THEN (12 - rr.cat) ELSE NULL::integer END)::text, ((rr.pct_of_companies)::numeric(4,3))::text, (CASE WHEN (numrange(CASE WHEN (rr.cat = 1) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 2))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END, CASE WHEN (rr.cat = 11) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 1))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END) @> v.ratiovalue) THEN 'stroke-color: #000000; stroke-width: 2; fill-color: '::text ELSE ''::text END || CASE WHEN (rr.score_id = ANY ('{4,5,6}'::integer[])) THEN t_clr.hexclr WHEN (rr.score_id = ANY ('{1,2,3}'::integer[])) THEN t_clr.hexclr_inv ELSE '#ffffff'::text END), CASE WHEN (numrange(CASE WHEN (rr.cat = 1) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 2))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END, CASE WHEN (rr.cat = 11) THEN NULL::numeric ELSE (r.reasonable_range_min + ((((rr.cat - 1))::numeric * (r.reasonable_range_max - r.reasonable_range_min)) / '9'::numeric)) END) @> v.ratiovalue) THEN 'X'::text ELSE ''::text END])","v.ratiovalue","rv.rankvalue"],"Plan Width": 55,"Join Filter": "((rv.rankvalue)::integer <@ t_clr.scorerng)","Total Cost": 7216.12}}]
我已经真空分析了桌子。在AWS RDS服务器Postgres 9.6.8上运行
任何有关正在发生的事情的提示都将不胜感激。