나는 매우 느리게 작동 postgresql 기능이 있습니다. 쿼리 중 하나에 문제가 있습니다. 최적화 할 방법이 있습니까? 내가 만든 색인은별로 도움이되지 못했습니다. 매우 느린 SQL 삽입 쿼리
INSERT INTO aa_c_axis_doc_oper
SELECT a.pool_id,
l.lane_id,
a.axis_id,
l.id AS src_row_id,
a.running_sum_abs,
a.running_sum_abs_begin_max,
l.program_id
FROM aa_oper_axis AS a
INNER JOIN aa_src1 AS l
ON a.pool_id = l.pool_id
WHERE l.running_sum_abs_begin <= a.running_sum_abs_begin_max
AND a.running_sum_abs <= l.running_sum_abs
는
Insert on aa_c_axis_doc_oper (cost=0.00..19727005.41 rows=345535083 width=84) (actual time=5428290.637..5428290.637 rows=0 loops=1)
-> Nested Loop (cost=0.00..19727005.41 rows=345535083 width=84) (actual time=235.809..5348024.371 rows=9954308 loops=1)
-> Seq Scan on aa_oper_axis a (cost=0.00..50396.63 rows=6085633 width=72) (actual time=0.040..3351.155 rows=6012431 loops=1)
-> Index Scan using aa_src1_pool_id_running_sum_abs_begin_running_sum_abs_idx on aa_src1 l (cost=0.00..2.75 rows=57 width=34) (actual time=0.881..0.887 rows=2 loops=6012431)
Index Cond: ((pool_id = a.pool_id) AND (running_sum_abs_begin <= a.running_sum_abs_begin_max) AND (a.running_sum_abs <= running_sum_abs))
Total runtime: 5428290.775 ms
아마도 여기에 더 많은주의를 기울일 것입니다. (http://codereview.stackexchange.com/) 또는 [여기] (http://dba.stackexchange.com/) – Alexander
@Alexander ...하지만 당신은 할 수 있습니다. 마이그레이션을 위해 플래그를 지정하십시오. Madbw, 다른 곳에 다시 게시 할 필요는 없습니다. –
@CraigRinger 나는 그것을 몰랐다. 고마워. 사실, 그건 단지 제안이었습니다. 확실하지 않습니다. – Alexander