贴出 explain select ..
及 show index from ..
以供分析。

解决方案 »

  1.   

    那参考一下PostgreSQL: Documentation:
    看看如何查看执行计划和索引统计。
      

  2.   

    1、account_id=a.id
     这个条件完全可以不用的
    2、试试这个语句:
    SELECT  count(id) FROM accounts as a 
    LEFT JOIN 
    (
     SELECT account_id,COUNT(account_id) AS c_aid FROM orders GROUP BY account_id;
    )b ON (a.id=b.account_id)
    WHERE date_entered<'2014-03-01' AND b.c_aid>=1 AND b.c_aid<=3;3、`date_entered`字段必须加索引;
      

  3.   

    一些情况下 join 比 exists 效用好多了,但是我不清楚是什么情况,楼主这段SQL试着join一下看看效果。