######## rep_subject_pass_rate ########
Sort  (cost=12506.58..12508.08 rows=600 width=146) (actual time=144.585..144.826 rows=6000.00 loops=1)
  Sort Key: a.year, a.type, (round(((100.0 * ((count(ps.id)))::numeric) / ((count(ss.id)))::numeric), 1)) DESC, s.code
  Sort Method: quicksort  Memory: 747kB
  Buffers: shared hit=2577
  ->  Hash Left Join  (cost=12291.46..12478.89 rows=600 width=146) (actual time=121.918..131.279 rows=6000.00 loops=1)
        Hash Cond: (ss.subjects_id = sa.subject_id)
        Buffers: shared hit=2566
        ->  Hash Left Join  (cost=8303.20..8474.03 rows=600 width=86) (actual time=87.591..93.282 rows=6000.00 loops=1)
              Hash Cond: ((ss.subjects_id = sps.subject_id) AND (es.semester_id = sps.semester_id))
              Buffers: shared hit=1699
              ->  Hash Join  (cost=5672.27..5839.95 rows=600 width=82) (actual time=60.453..64.892 rows=6000.00 loops=1)
                    Hash Cond: (ss.subjects_id = s.id)
                    Buffers: shared hit=1035
                    ->  Hash Join  (cost=5662.52..5828.60 rows=600 width=64) (actual time=60.342..63.712 rows=6000.00 loops=1)
                          Hash Cond: (es.semester_id = a.id)
                          Buffers: shared hit=1032
                          ->  HashAggregate  (cost=5661.07..5751.07 rows=6000 width=56) (actual time=60.314..62.727 rows=6000.00 loops=1)
                                Group Key: ss.subjects_id, es.semester_id
                                Batches: 1  Memory Usage: 1169kB
                                Buffers: shared hit=1031
                                ->  Hash Left Join  (cost=2131.00..3861.07 rows=80000 width=20) (actual time=14.127..42.476 rows=80000.00 loops=1)
                                      Hash Cond: (ss.id = ps.enrolled_id)
                                      Buffers: shared hit=1021
                                      ->  Hash Join  (cost=514.00..2034.06 rows=80000 width=12) (actual time=4.015..21.140 rows=80000.00 loops=1)
                                            Hash Cond: (ss.enrolled_semesters_id = es.id)
                                            Buffers: shared hit=664
                                            ->  Seq Scan on semesters_subjects ss  (cost=0.00..1310.00 rows=80000 width=12) (actual time=0.007..3.658 rows=80000.00 loops=1)
                                                  Buffers: shared hit=510
                                            ->  Hash  (cost=314.00..314.00 rows=16000 width=8) (actual time=3.885..3.886 rows=16000.00 loops=1)
                                                  Buckets: 16384  Batches: 1  Memory Usage: 753kB
                                                  Buffers: shared hit=154
                                                  ->  Seq Scan on enrolled_semesters es  (cost=0.00..314.00 rows=16000 width=8) (actual time=0.011..2.191 rows=16000.00 loops=1)
                                                        Buffers: shared hit=154
                                      ->  Hash  (cost=917.00..917.00 rows=56000 width=12) (actual time=10.032..10.037 rows=56000.00 loops=1)
                                            Buckets: 65536  Batches: 1  Memory Usage: 2919kB
                                            Buffers: shared hit=357
                                            ->  Seq Scan on passed_subjects ps  (cost=0.00..917.00 rows=56000 width=12) (actual time=0.011..4.648 rows=56000.00 loops=1)
                                                  Buffers: shared hit=357
                          ->  Hash  (cost=1.20..1.20 rows=20 width=12) (actual time=0.020..0.021 rows=20.00 loops=1)
                                Buckets: 1024  Batches: 1  Memory Usage: 9kB
                                Buffers: shared hit=1
                                ->  Seq Scan on active_semesters a  (cost=0.00..1.20 rows=20 width=12) (actual time=0.013..0.014 rows=20.00 loops=1)
                                      Buffers: shared hit=1
                    ->  Hash  (cost=6.00..6.00 rows=300 width=22) (actual time=0.106..0.107 rows=300.00 loops=1)
                          Buckets: 1024  Batches: 1  Memory Usage: 25kB
                          Buffers: shared hit=3
                          ->  Seq Scan on subjects s  (cost=0.00..6.00 rows=300 width=22) (actual time=0.022..0.058 rows=300.00 loops=1)
                                Buffers: shared hit=3
              ->  Hash  (cost=2540.93..2540.93 rows=6000 width=16) (actual time=27.095..27.097 rows=6000.00 loops=1)
                    Buckets: 8192  Batches: 1  Memory Usage: 346kB
                    Buffers: shared hit=664
                    ->  Subquery Scan on sps  (cost=2420.93..2540.93 rows=6000 width=16) (actual time=24.841..25.970 rows=6000.00 loops=1)
                          Buffers: shared hit=664
                          ->  HashAggregate  (cost=2420.93..2480.93 rows=6000 width=16) (actual time=24.840..25.553 rows=6000.00 loops=1)
                                Group Key: ss_1.subjects_id, es_1.semester_id
                                Batches: 1  Memory Usage: 409kB
                                Buffers: shared hit=664
                                ->  Hash Join  (cost=514.00..1978.79 rows=58952 width=12) (actual time=2.722..16.183 rows=58801.00 loops=1)
                                      Hash Cond: (ss_1.enrolled_semesters_id = es_1.id)
                                      Buffers: shared hit=664
                                      ->  Seq Scan on semesters_subjects ss_1  (cost=0.00..1310.00 rows=58952 width=12) (actual time=0.013..5.469 rows=58801.00 loops=1)
                                            Filter: signature
                                            Rows Removed by Filter: 21199
                                            Buffers: shared hit=510
                                      ->  Hash  (cost=314.00..314.00 rows=16000 width=8) (actual time=2.674..2.675 rows=16000.00 loops=1)
                                            Buckets: 16384  Batches: 1  Memory Usage: 753kB
                                            Buffers: shared hit=154
                                            ->  Seq Scan on enrolled_semesters es_1  (cost=0.00..314.00 rows=16000 width=8) (actual time=0.007..1.310 rows=16000.00 loops=1)
                                                  Buffers: shared hit=154
        ->  Hash  (cost=3984.51..3984.51 rows=300 width=36) (actual time=34.300..34.301 rows=300.00 loops=1)
              Buckets: 1024  Batches: 1  Memory Usage: 21kB
              Buffers: shared hit=867
              ->  Subquery Scan on sa  (cost=3977.01..3984.51 rows=300 width=36) (actual time=34.162..34.262 rows=300.00 loops=1)
                    Buffers: shared hit=867
                    ->  HashAggregate  (cost=3977.01..3981.51 rows=300 width=36) (actual time=34.162..34.248 rows=300.00 loops=1)
                          Group Key: ss_2.subjects_id
                          Batches: 1  Memory Usage: 80kB
                          Buffers: shared hit=867
                          ->  Hash Join  (cost=1617.00..3137.01 rows=56000 width=8) (actual time=9.343..23.919 rows=56000.00 loops=1)
                                Hash Cond: (ss_2.id = ps_1.enrolled_id)
                                Buffers: shared hit=867
                                ->  Seq Scan on semesters_subjects ss_2  (cost=0.00..1310.00 rows=80000 width=8) (actual time=0.018..2.738 rows=80000.00 loops=1)
                                      Buffers: shared hit=510
                                ->  Hash  (cost=917.00..917.00 rows=56000 width=8) (actual time=9.245..9.245 rows=56000.00 loops=1)
                                      Buckets: 65536  Batches: 1  Memory Usage: 2700kB
                                      Buffers: shared hit=357
                                      ->  Seq Scan on passed_subjects ps_1  (cost=0.00..917.00 rows=56000 width=8) (actual time=0.008..3.894 rows=56000.00 loops=1)
                                            Buffers: shared hit=357
Planning:
  Buffers: shared hit=355
Planning Time: 11.195 ms
Execution Time: 146.018 ms
-- OK explain_rep_subject_pass_rate.sql
