他的回复:
SET EXPLAIN_PERF_MODE=PRETTY;EXPLAIN ANALYZEselect T1.NDAH ,ROW_NUMBER() OVER(ORDER BY ZJE DESC) PM_RNFROM ( SELECT A.NDAH ,ZJE FROM ( SELECT T.NDAH ,NVL(T.HZBM, '-1') ,SUM(NVL(JE1,0)+NVL(JE2,0)) ZJE FROM LS_TEST202001615 T WHERE T.SSND = 2020 AND T.SSND >= SUBSTR ( 20180101,1 , 4 ) GROUP BY T.NDAH ,NVL(T.HZBM, '-1')) A /*ORDER BY ZJE DESC*/ ) T1;WindowAgg (cost=66.24..66.26 rows=270 width=130) (actual time=26152.524..2827606.659 rows=817926144 loops=1) -> Streaming (type: GATHER) (cost=66.30..74.84 rows=270 width=130) (actual time=26152.510..2412643.095 rows=817926144 loops=1) Merge Sort Key: a.ZJE DESC Node/s: All datanodes -> Sort (cost=66.24..66.24 rows=270 width=130) (actual time=[18233.441,19622.190]..[26080.098,28233.974], rows=817926144) Sort Key: a.ZJE DESC Sort Method: quicksort Memory: 330909kB ~ 340031kB -> Subquery Scan on a (cost=66.21..66.23 rows=270 width=130) (actual time=[12948.105,15684.100]..[18132.506,22532.986], rows=817926144) -> HashAggregate (cost=66.21..66.22 rows=270 width=392) (actual time=[12948.102,15037.583]..[18132.504,21828.672], rows=817926144) Group By Key: t.ndah, COALESCE(t.hzbm, '-1'::character varying) -> Seq Scan on ls_test202001615 t (cost=0.00..66.14 rows=300 width=360) (actual time=[0.097,5086.924]..[0.812,6979.154], rows=1508845497) Filter: (((ssnd)::text >= '2018'::text) AND ((ssnd)::bigint = 2020))Total runtime: 2958853.028 ms