Quick question about Filters on Growthbook fact ta...
# ask-questions
e
Quick question about Filters on Growthbook fact tables. The docs on filters read:
If a metric uses this Filter, GrowthBook will add it to the WHERE clause automatically. If there are multiple Filters, they will be ANDed together.
However, inspecting the generated SQL query reveals filters are inserted as a column in the SELECT statement as
SELECT CASE WHEN [[filter]] ELSE NULL
. I believe these are functionally different with respect to certain table operations involving indexes. Curious if anyone knows why this design decision was made and/or if the documentation needs to be updated to describe this discrepancy?
👀 1
s
Hi Matthew, I'm a data scientist at GrowthBook. Thanks for your question. One reason we employ
SELECT CASE WHEN
rather than
WHERE
is that a
WHERE
statement will affect all metrics in a fact table, while
SELECT CASE WHEN
affects only the metric with the filter. Luke
✅ 1
e
Makes sense to me! This came up because I wanted the saved filters to take advantage of a filtered index set on our database, but because the filter didn't actually filter the returned rows (for the exact reason you described) the filtered index can't be used properly.