Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- explain analyze SELECT DISTINCT(record),
- COALESCE(n72.quality, 0) + COALESCE(n73.quality, 0) + COALESCE(n74.quality, 0) + COALESCE(n75.quality, 0) + COALESCE(n76.quality, 0) + COALESCE(n77.quality, 0) AS quality
- FROM
- (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '020' AND mfr.subfield = 'a' AND (LOWER(mfr.value) LIKE '9781492629887%' OR LOWER(mfr.value) LIKE '149262988x%')) n72
- FULL OUTER JOIN (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '022' AND mfr.subfield = 'a' AND (LOWER(mfr.value) LIKE NULL)) n73 USING (record)
- FULL OUTER JOIN (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '024' AND mfr.subfield = 'a' AND (LOWER(mfr.value) LIKE NULL)) n74 USING (record)
- FULL OUTER JOIN (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '028' AND mfr.subfield = 'a' AND (mfr.value = NULL)) n75 USING (record)
- FULL OUTER JOIN (SELECT *, id AS record, 16 AS quality FROM metabib.record_attr_flat mraf WHERE mraf.attr = 'bib_level' AND mraf.value = 'm') n76 USING (record)
- FULL OUTER JOIN (SELECT *, id AS record, 16 AS quality FROM metabib.record_attr_flat mraf WHERE mraf.attr = 'item_type' AND mraf.value = 'a') n77 USING (record)
- JOIN biblio.record_entry bre ON (bre.id = record)
- WHERE (((n72.id IS NOT NULL) OR (n73.id IS NOT NULL) OR (n74.id IS NOT NULL) OR (n75.id IS NOT NULL)) AND (n76.id IS NOT NULL) AND (n77.id IS NOT NULL)) AND not bre.deleted;
- result:
- QUERY PLAN
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- HashAggregate (cost=11498437.71..11498437.76 rows=2 width=72) (actual time=12840.131..12840.133 rows=1 loops=1)
- Group Key: COALESCE(COALESCE(COALESCE(COALESCE(COALESCE(real_full_rec.record, real_full_rec_1.record), real_full_rec_2.record), real_full_rec_3.record), mraf.id), mraf_1.id), (((((COALESCE((2), 0) + COALESCE((2), 0)) + COALESCE((2), 0)) + COALESCE((2), 0)) + COALESCE((16), 0)) + COALESCE((16), 0))
- -> Hash Join (cost=9948150.47..11364916.07 rows=26704328 width=72) (actual time=12840.104..12840.112 rows=2 loops=1)
- Hash Cond: (COALESCE(COALESCE(COALESCE(COALESCE(COALESCE(real_full_rec.record, real_full_rec_1.record), real_full_rec_2.record), real_full_rec_3.record), mraf.id), mraf_1.id) = bre.id)
- -> Merge Join (cost=9165034.80..9776985.86 rows=40793432 width=72) (actual time=10068.682..10068.688 rows=2 loops=1)
- Merge Cond: (mraf_1.id = (COALESCE(COALESCE(COALESCE(COALESCE(real_full_rec.record, real_full_rec_1.record), real_full_rec_2.record), real_full_rec_3.record), mraf.id)))
- -> Sort (cost=207563.86..207588.65 rows=9916 width=12) (actual time=4620.808..4943.388 rows=1498506 loops=1)
- Sort Key: mraf_1.id
- Sort Method: quicksort Memory: 122345kB
- -> Subquery Scan on mraf_1 (cost=206707.34..206905.66 rows=9916 width=12) (actual time=2782.914..3855.859 rows=1561443 loops=1)
- -> HashAggregate (cost=206707.34..206806.50 rows=9916 width=22) (actual time=2782.909..3500.596 rows=1561443 loops=1)
- Group Key: v.source, m.attr, m.value
- -> Append (cost=0.28..206632.97 rows=9916 width=22) (actual time=0.119..1595.257 rows=1561443 loops=1)
- -> Nested Loop (cost=0.28..103255.63 rows=4410 width=17) (actual time=0.038..0.038 rows=0 loops=1)
- Join Filter: (m.id = ANY (v.vlist))
- -> Index Scan using muv_once_idx on uncontrolled_record_attr_value m (cost=0.28..6.23 rows=1 width=17) (actual time=0.035..0.035 rows=0 loops=1)
- Index Cond: ((attr = 'item_type'::text) AND (value = 'a'::text))
- -> Seq Scan on record_attr_vector_list v (cost=0.00..62760.20 rows=1799520 width=111) (never executed)
- Filter: (source IS NOT NULL)
- -> Nested Loop (cost=3.42..103278.18 rows=5506 width=26) (actual time=0.079..1321.168 rows=1561443 loops=1)
- Join Filter: (c.id = ANY (v_1.vlist))
- Rows Removed by Join Filter: 238115
- -> Bitmap Heap Scan on coded_value_map c (cost=3.42..28.78 rows=1 width=22) (actual time=0.050..0.071 rows=1 loops=1)
- Recheck Cond: (ctype = 'item_type'::text)
- Filter: (code = 'a'::text)
- Rows Removed by Filter: 18
- Heap Blocks: exact=3
- -> Bitmap Index Scan on config_coded_value_map_ctype_idx (cost=0.00..3.42 rows=19 width=0) (actual time=0.025..0.025 rows=19 loops=1)
- Index Cond: (ctype = 'item_type'::text)
- -> Seq Scan on record_attr_vector_list v_1 (cost=0.00..62760.20 rows=1799520 width=111) (actual time=0.009..529.943 rows=1799558 loops=1)
- Filter: (source IS NOT NULL)
- -> Sort (cost=8957470.94..8959527.89 rows=822780 width=60) (actual time=4899.926..4899.926 rows=2 loops=1)
- Sort Key: (COALESCE(COALESCE(COALESCE(COALESCE(real_full_rec.record, real_full_rec_1.record), real_full_rec_2.record), real_full_rec_3.record), mraf.id))
- Sort Method: quicksort Memory: 25kB
- -> Hash Right Join (cost=5983300.16..8876632.20 rows=822780 width=60) (actual time=4620.009..4899.869 rows=2 loops=1)
- Hash Cond: (COALESCE(COALESCE(COALESCE(real_full_rec.record, real_full_rec_1.record), real_full_rec_2.record), real_full_rec_3.record) = mraf.id)
- Filter: ((real_full_rec.id IS NOT NULL) OR (real_full_rec_1.id IS NOT NULL) OR (real_full_rec_2.id IS NOT NULL) OR (real_full_rec_3.id IS NOT NULL))
- Rows Removed by Filter: 1784954
- -> Hash Full Join (cost=5776281.25..8640766.20 rows=16595 width=80) (actual time=0.406..0.501 rows=2 loops=1)
- Hash Cond: (COALESCE(COALESCE(real_full_rec.record, real_full_rec_1.record), real_full_rec_2.record) = real_full_rec_3.record)
- -> Hash Full Join (cost=2911924.84..5776347.55 rows=16595 width=60) (actual time=0.351..0.443 rows=2 loops=1)
- Hash Cond: (COALESCE(real_full_rec.record, real_full_rec_1.record) = real_full_rec_2.record)
- -> Hash Full Join (cost=47568.42..2911928.90 rows=16595 width=40) (actual time=0.333..0.419 rows=2 loops=1)
- Hash Cond: (real_full_rec_1.record = real_full_rec.record)
- -> Result (cost=0.00..2864356.40 rows=1 width=20) (actual time=0.001..0.001 rows=0 loops=1)
- One-Time Filter: false
- -> Seq Scan on real_full_rec real_full_rec_1 (cost=0.00..2864356.40 rows=1 width=20) (never executed)
- -> Hash (cost=47360.99..47360.99 rows=16595 width=20) (actual time=0.136..0.136 rows=2 loops=1)
- Buckets: 32768 Batches: 1 Memory Usage: 257kB
- -> Bitmap Heap Scan on real_full_rec (cost=522.95..47360.99 rows=16595 width=20) (actual time=0.122..0.129 rows=2 loops=1)
- Recheck Cond: (((tag = '020'::bpchar) AND (subfield = 'a'::text) AND (lower("substring"(value, 1, 1024)) ~~ '9781492629887%'::text)) OR ((tag = '020'::bpchar) AND (subfield = 'a'::text) AND (lower("substring"(value, 1, 1024)) ~~ '149262988x%'::text)))
- Filter: ((lower("substring"(value, 1, 1024)) ~~ '9781492629887%'::text) OR (lower("substring"(value, 1, 1024)) ~~ '149262988x%'::text))
- Heap Blocks: exact=3
- -> BitmapOr (cost=522.95..522.95 rows=16636 width=0) (actual time=0.084..0.084 rows=0 loops=1)
- -> Bitmap Index Scan on metabib_full_rec_02x_tag_subfield_lower_substring (cost=0.00..257.32 rows=8318 width=0) (actual time=0.064..0.064 rows=2 loops=1)
- Index Cond: ((tag = '020'::bpchar) AND (subfield = 'a'::text) AND (lower("substring"(value, 1, 1024)) >= '9781492629887'::text) AND (lower("substring"(value, 1, 1024)) < '9781492629888'::text))
- -> Bitmap Index Scan on metabib_full_rec_02x_tag_subfield_lower_substring (cost=0.00..257.32 rows=8318 width=0) (actual time=0.019..0.019 rows=2 loops=1)
- Index Cond: ((tag = '020'::bpchar) AND (subfield = 'a'::text) AND (lower("substring"(value, 1, 1024)) >= '149262988x'::text) AND (lower("substring"(value, 1, 1024)) < '149262988y'::text))
- -> Hash (cost=2864356.40..2864356.40 rows=1 width=20) (actual time=0.002..0.002 rows=0 loops=1)
- Buckets: 1024 Batches: 1 Memory Usage: 8kB
- -> Result (cost=0.00..2864356.40 rows=1 width=20) (actual time=0.000..0.000 rows=0 loops=1)
- One-Time Filter: false
- -> Seq Scan on real_full_rec real_full_rec_2 (cost=0.00..2864356.40 rows=1 width=20) (never executed)
- -> Hash (cost=2864356.40..2864356.40 rows=1 width=20) (actual time=0.004..0.004 rows=0 loops=1)
- Buckets: 1024 Batches: 1 Memory Usage: 8kB
- -> Result (cost=0.00..2864356.40 rows=1 width=20) (actual time=0.002..0.002 rows=0 loops=1)
- One-Time Filter: false
- -> Seq Scan on real_full_rec real_full_rec_3 (cost=0.00..2864356.40 rows=1 width=20) (never executed)
- -> Hash (cost=206894.96..206894.96 rows=9916 width=12) (actual time=4619.520..4619.520 rows=1784955 loops=1)
- Buckets: 2097152 (originally 16384) Batches: 1 (originally 1) Memory Usage: 93082kB
- -> Subquery Scan on mraf (cost=206696.64..206894.96 rows=9916 width=12) (actual time=2881.340..4088.064 rows=1784955 loops=1)
- -> HashAggregate (cost=206696.64..206795.80 rows=9916 width=22) (actual time=2881.335..3675.337 rows=1784955 loops=1)
- Group Key: v_2.source, m_1.attr, m_1.value
- -> Append (cost=0.28..206622.27 rows=9916 width=22) (actual time=0.120..1612.990 rows=1784955 loops=1)
- -> Nested Loop (cost=0.28..103255.63 rows=4410 width=17) (actual time=0.041..0.041 rows=0 loops=1)
- Join Filter: (m_1.id = ANY (v_2.vlist))
- -> Index Scan using muv_once_idx on uncontrolled_record_attr_value m_1 (cost=0.28..6.23 rows=1 width=17) (actual time=0.038..0.038 rows=0 loops=1)
- Index Cond: ((attr = 'bib_level'::text) AND (value = 'm'::text))
- -> Seq Scan on record_attr_vector_list v_2 (cost=0.00..62760.20 rows=1799520 width=111) (never executed)
- Filter: (source IS NOT NULL)
- -> Nested Loop (cost=3.33..103267.49 rows=5506 width=26) (actual time=0.077..1295.323 rows=1784955 loops=1)
- Join Filter: (c_1.id = ANY (v_3.vlist))
- Rows Removed by Join Filter: 14603
- -> Bitmap Heap Scan on coded_value_map c_1 (cost=3.33..18.09 rows=1 width=22) (actual time=0.049..0.074 rows=1 loops=1)
- Recheck Cond: (ctype = 'bib_level'::text)
- Filter: (code = 'm'::text)
- Rows Removed by Filter: 6
- Heap Blocks: exact=4
- -> Bitmap Index Scan on config_coded_value_map_ctype_idx (cost=0.00..3.33 rows=7 width=0) (actual time=0.021..0.021 rows=7 loops=1)
- Index Cond: (ctype = 'bib_level'::text)
- -> Seq Scan on record_attr_vector_list v_3 (cost=0.00..62760.20 rows=1799520 width=111) (actual time=0.009..512.828 rows=1799558 loops=1)
- Filter: (source IS NOT NULL)
- -> Hash (cost=760178.72..760178.72 rows=1834956 width=8) (actual time=2755.076..2755.076 rows=1709519 loops=1)
- Buckets: 2097152 Batches: 1 Memory Usage: 83163kB
- -> Seq Scan on record_entry bre (cost=0.00..760178.72 rows=1834956 width=8) (actual time=0.021..2007.377 rows=1709519 loops=1)
- Filter: (NOT deleted)
- Rows Removed by Filter: 895801
- Planning time: 8.898 ms
- Execution time: 12846.116 ms
- (99 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement