分布键join+limit优化 explain analyze select t1. from t1,t2 where t1.f1t2.f1 limit 10; QUERY PLAN Limit (cost100.25..101.70 rows10 width367) (actual time1.527..3.899 rows10 loops1) > Remote Subquery Scan on all (dn01,dn02,dn03,dn04,dn05,dn06,dn07,dn08,dn09,dn10) (cost100.25..101.70 rows10 width367) (actual time1.525..1.529 rows10 loops1) Planning time: 0.360 ms Execution time: 18.193 ms (4 rows) Time: 19.921 ms 可以看到,preferolap设置为on后,计算、排序和limit过滤在DN上完成,返回CN的数量是每个DN节点limit之后的数据,解决了上面SQL优化前大量数据上拉CN节点的问题,性能提升了150倍。 这里也说明,preferolap参数使用也和SQL特点有关,如果将preferolap设置off,SQL需要拉大量数据到CN计算的话,性能会明显下降,我们在设置preferolap参数前一定要做好评估。