পোস্টগ্রিএসকিউএল 9.2
আমি Hash Semi Joinএবং ন্যায্য মধ্যে পার্থক্য বুঝতে চেষ্টা করছি Hash Join।
এখানে দুটি প্রশ্ন রয়েছে:
আমি
EXPLAIN ANALYZE SELECT * FROM orders WHERE customerid IN (SELECT
customerid FROM customers WHERE state='MD');
Hash Semi Join (cost=740.34..994.61 rows=249 width=30) (actual time=2.684..4.520 rows=120 loops=1)
Hash Cond: (orders.customerid = customers.customerid)
-> Seq Scan on orders (cost=0.00..220.00 rows=12000 width=30) (actual time=0.004..0.743 rows=12000 loops=1)
-> Hash (cost=738.00..738.00 rows=187 width=4) (actual time=2.664..2.664 rows=187 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 7kB
-> Seq Scan on customers (cost=0.00..738.00 rows=187 width=4) (actual time=0.018..2.638 rows=187 loops=1)
Filter: ((state)::text = 'MD'::text)
Rows Removed by Filter: 19813
দ্বিতীয়
EXPLAIN ANALYZE SELECT * FROM orders o JOIN customers c ON o.customerid = c.customerid WHERE c.state = 'MD'
Hash Join (cost=740.34..1006.46 rows=112 width=298) (actual time=2.831..4.762 rows=120 loops=1)
Hash Cond: (o.customerid = c.customerid)
-> Seq Scan on orders o (cost=0.00..220.00 rows=12000 width=30) (actual time=0.004..0.768 rows=12000 loops=1)
-> Hash (cost=738.00..738.00 rows=187 width=268) (actual time=2.807..2.807 rows=187 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 37kB
-> Seq Scan on customers c (cost=0.00..738.00 rows=187 width=268) (actual time=0.018..2.777 rows=187 loops=1)
Filter: ((state)::text = 'MD'::text)
Rows Removed by Filter: 19813
যেমন দেখা যায়, পরিকল্পনাগুলির মধ্যে একমাত্র পার্থক্য হ'ল প্রথম ক্ষেত্রে হুট করেই খাওয়া 7kBহয় তবে দ্বিতীয়টিতে 37kBএবং নোড হয় Hash Semi Join।
তবে হ্যাশটেবল আকারের পার্থক্যটি আমি বুঝতে পারি না। Hashনোড পুরোপুরি একই ব্যবহার Seq Scanএকই থাকার নোড Filter। কেন পার্থক্য আছে?
explain (analyze, verbose)।