Replies: 3 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
Interesting! I like this idea. Basically applying Divide & Conquer to querying database. I tried to make your diagram a bit clearer and added a I also numbered the arrows to represent each step in the algorithm. |
Beta Was this translation helpful? Give feedback.
-
So I have a better idea now. Say we want to parallelize 4 AND filters A, B, C, D We would then have (conceptually) 4 pipelines where we cycle their order and put each first
They are load-balanced so the ones running faster will process more items. This is a dynamic process, so if one pipeline is experiencing a slow down (e.g. page fetch) the others can still be busy running. At the end, there are 3 rules:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Consider the following query
Can we exectue the two filter conditions in parallel?
A traditional query planner would try to figure out which condition is cheaper and apply it first
For example, given
It's obvious that the equal condition is cheaper (especially if the id column is indexed), so the order would be:
But in cases where the filter conditions have different sources and it's not possible to determine which is cheaper, why not exectue them in parallel and see which completes first?
Consider the following query
(the reason where two %% is used is because it is impossible to utilize an index in this case, but it actually can be any scan operator)
I imagine the following algorithm:
The trick is to load balance the two processes.
If the input queue of one processor is empty, we will 'grab more' from the input queue of the other.
Since we are doing an AND operation, the rows rejected by the faster filter will not be piped into the slower filter, making the resultant query execution twice at fast at best, and equivalent to sequential filtering at worst.
But the benefit is we do not have to determine beforehand.
Beta Was this translation helpful? Give feedback.
All reactions