Обсуждение: Adding Zigzag Merge Join to Index Nested Loops Join

Поиск
Список
Период
Сортировка

Adding Zigzag Merge Join to Index Nested Loops Join

От
tubadzin
Дата:
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

Re: Adding Zigzag Merge Join to Index Nested Loops Join

От
Robert Haas
Дата:
On Tue, Jul 23, 2013 at 3:40 PM, tubadzin <tubadzin@o2.pl> wrote:
> 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

nodeNestloop.c handles all execution of all nested loops, regardless
of whether there's an index scan involved.  Of course, if there is an
index scan involved, then nodeIndexscan.c will also be involved; if
there is an index-only scan, then nodeIndexonlyscan.c, and so on.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: Adding Zigzag Merge Join to Index Nested Loops Join

От
Jeff Janes
Дата:
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