проанализировать план: |QUERY PLAN                                                                                                                                                                     |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|Nested Loop  (cost=0.00..69396485.43 rows=27792 width=610) (actual time=79647.670..79647.685 rows=0 loops=1)                                                                   |
|  Join Filter: (t.talon_id = t_1.talon_id)                                                                                                                                     |
|  Rows Removed by Join Filter: 1486516                                                                                                                                         |
|  ->  Append  (cost=0.00..69285315.26 rows=2779192 width=820) (actual time=0.973..79231.311 rows=1486516 loops=1)                                                              |
|        ->  Seq Scan on eq_talon t_1  (cost=0.00..36107269.60 rows=1453181 width=2116) (actual time=0.972..59257.558 rows=1453181 loops=1)                                     |
|              Filter: (talon_type_id = 1)                                                                                                                                      |
|              SubPlan 1                                                                                                                                                        |
|                ->  Seq Scan on tdic_eq_status t_4  (cost=0.00..1.06 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=1453181)                                          |
|                      Filter: (eq_status_id = t_1.status)                                                                                                                      |
|                      Rows Removed by Filter: 4                                                                                                                                |
|              SubPlan 2                                                                                                                                                        |
|                ->  Seq Scan on tdict_eq_equeue_type tt  (cost=0.00..1.32 rows=1 width=39) (actual time=0.001..0.002 rows=1 loops=1453181)                                     |
|                      Filter: (equeue_type_id = t_1.equeue_type_id)                                                                                                            |
|                      Rows Removed by Filter: 25                                                                                                                               |
|              SubPlan 3                                                                                                                                                        |
|                ->  Index Scan using case_history_pkey on case_history ch  (cost=0.43..3.04 rows=1 width=11) (actual time=0.002..0.002 rows=0 loops=1453181)                   |
|                      Index Cond: (folder = t_1.case_history)                                                                                                                  |
|              SubPlan 4                                                                                                                                                        |
|                ->  Aggregate  (cost=16.39..16.40 rows=1 width=8) (actual time=0.031..0.031 rows=1 loops=1453181)                                                              |
|                      ->  Index Scan using ix_oc_case_hist on order_control oc  (cost=0.43..16.39 rows=1 width=8) (actual time=0.031..0.031 rows=0 loops=1453181)              |
|                            Index Cond: (case_history_id = t_1.case_history)                                                                                                   |
|                            Filter: ((status = 8) AND (date_trunc('day'::text, time_start_plan) = date_trunc('day'::text, (CURRENT_DATE)::timestamp with time zone)))          |
|                            Rows Removed by Filter: 8                                                                                                                          |
|              SubPlan 5                                                                                                                                                        |
|                ->  Index Scan using staff_pkey on staff f  (cost=0.28..2.90 rows=1 width=23) (actual time=0.001..0.001 rows=1 loops=1453181)                                  |
|                      Index Cond: (staff = t_1.staff)                                                                                                                          |
|        ->  Subquery Scan on "*SELECT* 2_1"  (cost=454.33..33164149.70 rows=1326011 width=664) (actual time=42.486..19817.724 rows=33335 loops=1)                              |
|              ->  Merge Join  (cost=454.33..33150889.59 rows=1326011 width=664) (actual time=42.483..19804.377 rows=33335 loops=1)                                             |
|                    Merge Cond: (t_2.talon_id = a.talon_id)                                                                                                                    |
|                    Join Filter: (a.eq_type_id <> t_2.equeue_type_id)                                                                                                          |
|                    Rows Removed by Join Filter: 1433775                                                                                                                       |
|                    ->  Index Scan using eq_talon_pkey on eq_talon t_2  (cost=0.43..56685.55 rows=1453181 width=94) (actual time=0.033..1044.512 rows=1453181 loops=1)         |
|                          Filter: (talon_type_id = 1)                                                                                                                          |
|                    ->  Index Scan using ix_talon_action on eq_talon_action a  (cost=0.43..164924.84 rows=1456080 width=24) (actual time=0.396..16346.701 rows=1467110 loops=1)|
|                          Index Cond: (action_id = ANY ('{0,4}'::bigint[]))                                                                                                    |
|                    SubPlan 6                                                                                                                                                  |
|                      ->  Seq Scan on tdic_eq_status t_5  (cost=0.00..1.06 rows=1 width=20) (actual time=0.001..0.002 rows=1 loops=33335)                                      |
|                            Filter: (eq_status_id = t_2.status)                                                                                                                |
|                            Rows Removed by Filter: 4                                                                                                                          |
|                    SubPlan 7                                                                                                                                                  |
|                      ->  Seq Scan on tdict_eq_equeue_type tt_1  (cost=0.00..1.32 rows=1 width=39) (actual time=0.001..0.002 rows=1 loops=33335)                               |
|                            Filter: (equeue_type_id = a.eq_type_id)                                                                                                            |
|                            Rows Removed by Filter: 25                                                                                                                         |
|                    SubPlan 8                                                                                                                                                  |
|                      ->  Index Scan using case_history_pkey on case_history ch_1  (cost=0.43..3.04 rows=1 width=11) (actual time=0.005..0.006 rows=1 loops=33335)             |
|                            Index Cond: (folder = t_2.case_history)                                                                                                            |
|                    SubPlan 9                                                                                                                                                  |
|                      ->  Aggregate  (cost=16.39..16.40 rows=1 width=8) (actual time=0.037..0.037 rows=1 loops=33335)                                                          |
|                            ->  Index Scan using ix_oc_case_hist on order_control oc_1  (cost=0.43..16.39 rows=1 width=8) (actual time=0.036..0.036 rows=0 loops=33335)        |
|                                  Index Cond: (case_history_id = t_2.case_history)                                                                                             |
|                                  Filter: ((status = 8) AND (date_trunc('day'::text, time_start_plan) = date_trunc('day'::text, (CURRENT_DATE)::timestamp with time zone)))    |
|                                  Rows Removed by Filter: 16                                                                                                                   |
|                    SubPlan 10                                                                                                                                                 |
|                      ->  Index Scan using staff_pkey on staff f_1  (cost=0.28..2.90 rows=1 width=23) (actual time=0.002..0.003 rows=1 loops=33335)                            |
|                            Index Cond: (staff = t_2.staff)                                                                                                                    |
|  ->  Materialize  (cost=0.00..2.49 rows=2 width=8) (actual time=0.000..0.000 rows=1 loops=1486516)                                                                            |
|        ->  Append  (cost=0.00..2.48 rows=2 width=8) (actual time=0.422..0.464 rows=1 loops=1)                                                                                 |
|              ->  Seq Scan on eq_window t  (cost=0.00..1.23 rows=1 width=8) (actual time=0.411..0.412 rows=1 loops=1)                                                          |
|                    Filter: (window_id = 10)                                                                                                                                   |
|                    Rows Removed by Filter: 17                                                                                                                                 |
|              ->  Subquery Scan on "*SELECT* 2"  (cost=0.00..1.25 rows=1 width=8) (actual time=0.038..0.040 rows=0 loops=1)                                                    |
|                    ->  Nested Loop  (cost=0.00..1.24 rows=1 width=1588) (actual time=0.037..0.039 rows=0 loops=1)                                                             |
|                          ->  Seq Scan on eq_window t_3  (cost=0.00..1.23 rows=1 width=16) (actual time=0.019..0.019 rows=1 loops=1)                                           |
|                                Filter: (window_id = 10)                                                                                                                       |
|                                Rows Removed by Filter: 11                                                                                                                     |
|                          ->  Seq Scan on eq_window_add a_1  (cost=0.00..0.00 rows=1 width=8) (actual time=0.017..0.018 rows=0 loops=1)                                        |
|                                Filter: (window_id = 10)                                                                                                                       |
|Planning Time: 18.216 ms                                                                                                                                                       |
|Execution Time: 79648.148 ms                                                                                                                                                   |