Skip to content

document useFilterCNF query context parameter#9647

Merged
clintropolis merged 5 commits intoapache:masterfrom
clintropolis:doc-useFilterCNF-context-parameter
Apr 17, 2020
Merged

document useFilterCNF query context parameter#9647
clintropolis merged 5 commits intoapache:masterfrom
clintropolis:doc-useFilterCNF-context-parameter

Conversation

@clintropolis
Copy link
Copy Markdown
Member

Does the thing the title says, and adds useFilterCNF to the query context docs. It might be worth adding a preamble of sorts to some of these settings to indicate that they are for advanced tuning and control over druid behavior, but i'm not sure what that should look like or what would be intuitive, so instead just focused on trying to impart that query issuers should experiment before using this setting in a production environment to confirm it is good for the filter shape.

public static final boolean DEFAULT_ENABLE_JOIN_FILTER_PUSH_DOWN = true;
public static final boolean DEFAULT_ENABLE_JOIN_FILTER_REWRITE = true;
public static final boolean DEFAULT_ENABLE_JOIN_FILTER_REWRITE_VALUE_COLUMN_FILTERS = false;
public static final long DEFAULT_ENABLE_JOIN_FILTER_REWRITE_MAX_SIZE_KEY = 10000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

|parallelMergeParallelism|`druid.processing.merge.pool.parallelism`|Maximum number of parallel threads to use for parallel result merging on the Broker. See [Broker configuration](../configuration/index.html#broker) for more details.|
|parallelMergeInitialYieldRows|`druid.processing.merge.task.initialYieldNumRows`|Number of rows to yield per ForkJoinPool merge task for parallel result merging on the Broker, before forking off a new task to continue merging sequences. See [Broker configuration](../configuration/index.html#broker) for more details.|
|parallelMergeSmallBatchRows|`druid.processing.merge.task.smallBatchNumRows`|Size of result batches to operate on in ForkJoinPool merge tasks for parallel result merging on the Broker. See [Broker configuration](../configuration/index.html#broker) for more details.|
|useFilterCNF|`false`| If true, Druid will attempt to convert the query filter to Conjunctive Normal Form (CNF). During query processing, columns can be pre-filtered by intersecting the bitmap indexes of all values that match the eligible filters, often greatly reducing the raw number of rows which need to be scanned. But this effect only happens for the top level filter, or individual clauses of a top level 'and' filter. As such, filters in CNF potentially have a higher chance to utilize a large amount of bitmap indexes on string columns during pre-filtering. However, this setting should be used with great caution, as it can sometimes have a negative effect on performance, and in some cases, the act of computing CNF of a filter can be expensive. We recommend hand tuning your filters to produce an optimal form if possible, or at least verifying through experimentation that using this parameter actually improves your query performance with no ill-effects.|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this effect only happens for the top level filter, or individual clauses of a top level 'and' filter.

Suggest providing a few examples to clarify:

  • An OR filter A || B where A can be resolved using bitmap indexes but B cannot will prevent the whole OR filter from being considered for pre-filtering
  • If it were A && B instead, A would be considered for pre-filtering but B would not.
  • If it were A && (C || D) where C and D can be resolved using bitmap indexes, then the whole filter can be considered for pre-filtering
  • If were A && (B || C) only A will be considered for pre-filtering

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think how filters work with query processing and how mechanically filters are split into pre and post filters should be documented somewhere, but I don't think this setting is quite the correct avenue. Additionally, since which filters can and can't use bitmaps isn't exactly documented anywhere, I'm not sure how much the examples would help.

If we added this general description of query processing and how filters are involved could link to this setting, and also could link to documentation we would add for the filterTuning added in #8209, as ways the user can help influence how filter processing behaves. Maybe segments.md would be an appropriate place since it mentions bitmaps and their role in filtering, or segment-optimization.md since it involves how to tune segment sizes? Or perhaps we need an advanced-tuning.md to put this and other stuff that users shouldn't really mess with unless they are prepared to roll up their sleeves and experimentally verify the settings to fine tune to their workload?

Should this be part of this PR, or done as a follow-up? It sort of blows up the scope a bit of what I was looking to do as part of this PR, but it also seems useful so I'm fine either way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be part of this PR, or done as a follow-up? It sort of blows up the scope a bit of what I was looking to do as part of this PR, but it also seems useful so I'm fine either way.

I think the filter tuning guide could be done in a follow-up, it sounds like something that would be much larger than this PR, this PR LGTM.

(There's a merge conflict in the spelling exclusions now)

@clintropolis clintropolis merged commit e677c62 into apache:master Apr 17, 2020
@clintropolis clintropolis deleted the doc-useFilterCNF-context-parameter branch April 17, 2020 05:12
suneet-s pushed a commit to suneet-s/druid that referenced this pull request May 10, 2020
* document useFilterCNF query context parameter

* move context key to QueryContexts

* Update .spelling
suneet-s added a commit to implydata/druid-public that referenced this pull request May 11, 2020
* Avoid sorting values in InDimFilter if possible (apache#9800)

* Avoid sorting values in InDimFilter if possible

* tests

* more tests

* fix and and or filters

* fix build

* false and true vector matchers

* fix vector matchers

* checkstyle

* in filter null handling

* remove wrong test

* address comments

* remove unnecessary null check

* redundant separator

* address comments

* typo

* tests

* Add equivalent test coverage for all RHS join impls (apache#9831)

* Add equivalent test coverage for all RHS join impls

* address comments

* Directly rewrite filters on RHS join columns into LHS equivalents (apache#9818)

* Directly rewrite filters on RHS join columns into LHS equivalents

* PR comments

* Fix inspection

* Revert unnecessary ExprMacroTable change

* Fix build after merge

* Address PR comments

* document useFilterCNF query context parameter (apache#9647)

* document useFilterCNF query context parameter

* move context key to QueryContexts

* Update .spelling

Co-authored-by: Jihoon Son <jihoonson@apache.org>
Co-authored-by: Maytas Monsereenusorn <52679095+maytasm@users.noreply.github.com>
Co-authored-by: Jonathan Wei <jon-wei@users.noreply.github.com>
Co-authored-by: Clint Wylie <cwylie@apache.org>
JulianJaffePinterest pushed a commit to JulianJaffePinterest/druid that referenced this pull request Jun 12, 2020
* document useFilterCNF query context parameter

* move context key to QueryContexts

* Update .spelling
@clintropolis clintropolis added this to the 0.19.0 milestone Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants