This message was deleted.
# general
s
This message was deleted.
a
How much cardinality do these columns have?
a
Not exactly sure of the number but it is url data for clickstream data
s
What is the regex? Will it be consistent at query time? If so perhaps you can apply a transformation that extracts a relevant portion at ingestion time so that you can apply a direct equality filter on the calculated column at query time.
a
So this is a contains filter basically and the url values are pretty long here. Also extracting relevant words here can be a bit of a task
j
A couple additional thoughts -- • Is there a simpler false-positive filter (e.g. like with trailing wildcard to match URL prefix, URL length, etc) that you can apply first with an AND condition, that will filter out most of the rows so the RegEx won't have to be applied to many rows? I believe Druid will short-circuit AND clauses in the filter for native queries. • Have you tried "like" instead of RegEx?
a
Copy code
{
  "type": "search",
  "dimension": "id",
  "query": {
    "type": "insensitive_contains",
    "value": "test"
  },
  "extractionFn": {
    "type": "lookup",
    "lookup": "master",
    "retainMissingValue": true
  }
}
This is how we are doing it currently
j
Is (case sensitive) "contains" significantly faster than "insensitive_contains"? Just thinking -- if it is, then if it's possible to store the index as all lowercase the search algorithm could potentially be made to be faster ... If not, then the only other thing I could think of to look at is if there is a trailing wildcard that could be used as a rough filter first before using the contains filter.
a
Copy code
{
  "filter": {
    "type": "and",
    "fields": [
      {
        "type": "search",
        "dimension": "name",
        "query": {
          "type": "insensitive_contains",
          "value": "contains 1"
        }
      },
      {
        "type": "not",
        "field": {
          "type": "in",
          "dimension": "name",
          "values": [
            "not equal 1"
          ]
        }
      },
      {
        "type": "or",
        "fields": [
          {
            "type": "bound",
            "dimension": "name",
            "lower": "1",
            "upper": "5"
          },
          {
            "type": "bound",
            "dimension": "name",
            "lower": "6",
            "upper": "10",
            "ordering": "numeric"
          }
        ]
      }
    ]
  }
}
So in the above filter, the insensitive_contains subquery is written before IN and the BOUND queries. Will it improve my performance if I reorder the filters inside the AND clause? Or the execution of the subqueries independent of each other here?
j
Hi AJ, I have tried reording filters in an AND group, from what I observed it would "short-circuit", which means if the first AND filter on the list evaluates to false, then it won't bother to evaluate the other filters on the list for that record that it is evaluating. So try putting the fastest processing filter first and see if that helps. In fact here even the OR condition would probably be better as the second AND filter, and put insensitive_contains last. Eager to hear if this helps ...