Postgres 9..0 쿼리 계획을 수정하는 방법에 대한 자세한 정보를 찾고 있습니다.Postgres 9.0 쿼리 계획 수정
"Aggregate (cost=1518.56..1518.57 rows=1 width=8) (actual time=410.459..410.459 rows=1 loops=1)"
" -> Bitmap Heap Scan on statistics_loged_users (cost=993.96..1518.55 rows=1 width=8) (actual time=410.025..410.406 rows=210 loops=1)"
" Recheck Cond: ((group_id = 3) AND (usr_id = 243431))"
" Filter: (school_id = 338)"
" -> BitmapAnd (cost=993.96..993.96 rows=133 width=0) (actual time=409.521..409.521 rows=0 loops=1)"
" -> Bitmap Index Scan on statistics_loged_users_idx2 (cost=0.00..496.85 rows=26669 width=0) (actual time=375.770..375.770 rows=3050697 loops=1)"
" Index Cond: (group_id = 3)"
" -> Bitmap Index Scan on statistics_loged_users_idx (cost=0.00..496.85 rows=26669 width=0) (actual time=0.077..0.077 rows=210 loops=1)"
" Index Cond: (usr_id = 243431)"
"Total runtime: 411.419 ms"
우리는 첫 번째 필터는 GROUP_ID입니다 볼 수 있습니다 출력을 분석
SELECT
max(creation_date)
FROM
statistics_loged_users
WHERE
school_id = 338 and
group_id = 3 and
usr_id = 243431;
그리고 설명 :
나는 쿼리가 있습니다. 이 테이블은 매우 큽니다 :) group_id가 같지만 동일한 usr_id를 가진 행이 훨씬 적은 행이 있습니다.
질문은 어떻게 첫 번째 필터가 usr_id 여야하는지 쿼리 계획에 알릴 수 있습니다.
내가 GROUP_ID 및 usr_id에 대한 인덱스를 생성하고 난 성능, 을 가지고 있지만, 거기에 내가 쿼리 계획을 수정하는 방법을 알고 있어야합니다, 그것은 미래 :)
추정 행 26,669, 실제 3,050,697. 나는 '진공 분석'이 순서라고 생각한다. 정기적으로 그렇게합니까? –