SQLSTATE58030,sqlstate28000
在最佳化一條SQL的時候遇到了執行錯誤
gtlions=# select t1.telnumber,t2.ua,t2.url,t1.apply_name,t2.apply_name from tb1 t1 gtlions-# left outer join tb2 t2 on t1.sid = t2.ipsid gtlions-# where t1.sum_date=20141128 and t1.sys_reported_time >= '2014-11-28 03:55:00' and t1.sys_reported_time <= '2014-11-28 04:00:00';ERROR: could not create temporary file base/20350/pgsql_tmp/workfile_set_HashJoin_Slice0.XXXXva5ffL/spillfile_f261961:Too many open filesERROR: could not seek in temporary file: Bad file descriptor
對應的SQLSTATE是58030,文檔上是這樣描述的
58030 IO ERROR io_error
檢查了下開啟檔案數以及系統限制
[root@mdw ~]# lsof -n|wc -l 23583[root@mdw ~]# ulimit -Hn131072[root@mdw ~]# ulimit -Sn131072
再次在執行過程中檢查下開啟的檔案數量發現已經遠遠超出了系統限制(14xxx),對此解決辦法是修改GPDB參數[statement_mem],可以在session level層級進行設定,將該值設定的足夠大以便容納的下臨時操作或者排序的資料。當然也要對錶進行統計分析,保證準確的統計資訊。
對於從4.2.8.2版本開始可以有專門的參數[gp_workfile_limit_files_per_query]設定開啟檔案數量的。
-EOF-