heavyai-charting icon indicating copy to clipboard operation
heavyai-charting copied to clipboard

Make heatmap simplify queries when all items on one axis are selected

Open mrblueblue opened this issue 7 years ago • 1 comments

Currently when one selects a whole row or column (or multiple rows or columns) on a heatmap, DC calls crossfilter in a way that generates a filter for every cell. This can get really expensive even on our backend at scale.

See below for the query that is generated when one selects the origin state of CA on one axis of flights.

screen shot 2017-02-07 at 8 25 55 pm

"SELECT COUNT(*) as val FROM flights_123M WHERE (origin_state = 'CA' AND dest_state = 'AK' OR origin_state = 'CA' AND dest_state = 'AR' OR origin_state = 'CA' AND dest_state = 'AZ' OR origin_state = 'CA' AND dest_state = 'CA' OR origin_state = 'CA' AND dest_state = 'CO' OR origin_state = 'CA' AND dest_state = 'CT' OR origin_state = 'CA' AND dest_state = 'FL' OR origin_state = 'CA' AND dest_state = 'GA' OR origin_state = 'CA' AND dest_state = 'HI' OR origin_state = 'CA' AND dest_state = 'IA' OR origin_state = 'CA' AND dest_state = 'ID' OR origin_state = 'CA' AND dest_state = 'IL' OR origin_state = 'CA' AND dest_state = 'IN' OR origin_state = 'CA' AND dest_state = 'KS' OR origin_state = 'CA' AND dest_state = 'KY' OR origin_state = 'CA' AND dest_state = 'LA' OR origin_state = 'CA' AND dest_state = 'MA' OR origin_state = 'CA' AND dest_state = 'MD' OR origin_state = 'CA' AND dest_state = 'ME' OR origin_state = 'CA' AND dest_state = 'MI' OR origin_state = 'CA' AND dest_state = 'MN' OR origin_state = 'CA' AND dest_state = 'MO' OR origin_state = 'CA' AND dest_state = 'MT' OR origin_state = 'CA' AND dest_state = 'NC' OR origin_state = 'CA' AND dest_state = 'ND' OR origin_state = 'CA' AND dest_state = 'NE' OR origin_state = 'CA' AND dest_state = 'NJ' OR origin_state = 'CA' AND dest_state = 'NM' OR origin_state = 'CA' AND dest_state = 'NV' OR origin_state = 'CA' AND dest_state = 'NY' OR origin_state = 'CA' AND dest_state = 'OH' OR origin_state = 'CA' AND dest_state = 'OK' OR origin_state = 'CA' AND dest_state = 'OR' OR origin_state = 'CA' AND dest_state = 'PA' OR origin_state = 'CA' AND dest_state = 'PR' OR origin_state = 'CA' AND dest_state = 'SD' OR origin_state = 'CA' AND dest_state = 'TN' OR origin_state = 'CA' AND dest_state = 'TX' OR origin_state = 'CA' AND dest_state = 'UT' OR origin_state = 'CA' AND dest_state = 'VA' OR origin_state = 'CA' AND dest_state = 'WA' OR origin_state = 'CA' AND dest_state = 'WI' OR origin_state = 'CA' AND dest_state = 'WY');"

This query could just as be easily represented as WHERE origin_state = 'CA'. Multiple columns and rows selected could simply be (row_var = 'A' or row_var = 'B' or col_var = 'C' or col_var = 'D'). Would be good to scope what it would take (likely simple) in the heatmap chart in DC to generate these simpler (and more performant) queries.

mrblueblue avatar Jun 22 '17 21:06 mrblueblue

I'd bump this task in priority since it will take a way for people to sledgehammer our backend. Should be quite simple.

tmostak avatar Jun 22 '17 21:06 tmostak