On Tue, Jul 23, 2013 at 12:40 PM, tubadzin <tubadzin@o2.pl> wrote:
> Hi.
> I want add Zigzag Merge join to Index Nested Loops Join alghoritm.
> http://www.cs.berkeley.edu/~fox/summaries/database/query_eval_5-8.html
> Which files are responsible for Index nested loops join ? (not simple nested
> loops join which has double foreach in nodeNestloop.c) nodeIndexscan.c?
> nodeIndexonlyscan.c?
> Best Regards
> Tom
As far as I can tell, a "zigzag merge" is nothing more than a nested
loop which uses an index scan on both the inner and outer. It seems a
bit strange to me to draw a box around that particular combination and
give it a specific name.
If that is what it really is, then there is nothing to implement.
PostgreSQL already does that when it thinks it is faster than the
alternatives.
pgbench -i -s10
set enable_seqscan TO off;
set enable_mergejoin TO off;
set enable_hashjoin TO off;
explain select * from pgbench_accounts join pgbench_branches using
(bid) where aid between 1 and 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------Nested Loop
(cost=0.58..25.21rows=4 width=457) -> Index Scan using pgbench_accounts_pkey on pgbench_accounts
(cost=0.43..8.51 rows=4 width=97) Index Cond: ((aid >= 1) AND (aid <= 5)) -> Index Scan using
pgbench_branches_pkeyon pgbench_branches
(cost=0.14..4.16 rows=1 width=364) Index Cond: (bid = pgbench_accounts.bid)
Cheers,
Jeff