From: | Ravi Kiran <ravi(dot)kolanpaka(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Hash function constant in the Hash join algorithm |
Date: | 2015-05-07 18:46:22 |
Message-ID: | CAOh57xFd6fU-ChUeEEcnvm=ieWqgDEpo4v1nOK3bCrd1HoCKvQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
As part part of my project, I had to compare the time taken by the Hashjoin
algorithm to that of Nested loop algorithm for the inner join and Natural
join queries, under two cases. I used six tables to join each other each
containing 5000 rows each approximately.
The two cases are given below.
1)When the hash function of the of hash join algorithm is not made to
return a constant value, In this case the time taken by the hashjoin
algorithm for the inner join is 1.45 secs and for the natural join is 4.58
secs and the time taken by the nested loop algorithm for inner join is
11.49 secs, and for natural join 46.94 secs.
2) when the hash function of the hash join algorithm is made to return a
constant value. Here, in the program hashfunc.c, I made all the hash
functions return a constant value. In this case the time taken by the
hashjoin algorithm for inner join is 8.44 secs and for natural join is
29.18 secs, and the time taken by the Nested loop algorithm for inner join
is 11.66 secs and for natural join is 46.9 secs.
According to my understanding when a hashfunction is made to return a
constant, all the tuples are hashed into a single bucket, and therefore the
hashjoin algorithm is converted into a nestedloop algorithm.
From the above two cases, I am understanding that even even when the hash
function is made to return a constant, The hashjoin agorithm is taking
significantly lower time compared to nested loop.
Could anyone explain why does the hashjoin algorithm takes significantly
lower time compared to nested loop when the hash function is made to return
a constant value or have I done any mistake at any part of the code?
Note - I am using the postgresql9.4 version for coding. I know the post is
long, There might be some grammar mistakes, I regret if I caused any
convenience to anyone.
Thank you.
--
Regards,
K.Ravikiran
ᐧ
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-05-07 18:49:28 | Re: Hash function constant in the Hash join algorithm |
Previous Message | cchee-ob | 2015-05-07 16:32:56 | Re: Getting UDR up and running |