You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Q6: How many social shares meet complex multi-stage filtering criteria?
135
+
**Question**: What is the count of sharing actions from iPhone mobile users on specific social networks, within common timezones, participating in seasonal campaigns, with high screen resolutions and closely matched UTM parameters?
136
+
**Important Query Properties**: Simple filter with high-selectivity, Costly string matching, A large number of filters with high overhead are positioned relatively later in the process
137
+
138
+
```sql
139
+
SELECTCOUNT(*) AS ShareCount
140
+
FROM hits
141
+
WHERE
142
+
-- Stage 1: High-selectivity filters (fast)
143
+
"IsMobile"=1-- Filter mobile users
144
+
AND"MobilePhoneModel"LIKE'iPhone%'-- Match iPhone models
145
+
AND"SocialAction"='share'-- Identify social sharing actions
146
+
147
+
-- Stage 2: Moderate filters (cheap)
148
+
AND"SocialSourceNetworkID"IN (5, 12) -- Filter specific social networks
149
+
AND"ClientTimeZone" BETWEEN -5AND5-- Restrict to common timezones
150
+
151
+
-- Stage 3: Heavy computations (expensive)
152
+
AND regexp_match("Referer", '\/campaign\/(spring|summer)_promo') IS NOT NULL-- Find campaign-specific referrers
153
+
AND CASE
154
+
WHEN split_part(split_part("URL", 'resolution=', 2), '&', 1) ~ '^\d+$'
155
+
THEN split_part(split_part("URL", 'resolution=', 2), '&', 1)::INT
156
+
ELSE 0
157
+
END >1920-- Extract and validate resolution parameter
158
+
AND levenshtein("UTMSource", "UTMCampaign") <3-- Verify UTM parameter similarity
159
+
```
160
+
Result is empty,Since it has already been filtered by `"SocialAction" = 'share'`.
SELECT"BrowserCountry", COUNT(DISTINCT "SocialNetwork"), COUNT(DISTINCT "HitColor"), COUNT(DISTINCT "BrowserLanguage"), COUNT(DISTINCT "SocialAction") FROM hits GROUP BY1ORDER BY2DESCLIMIT10;
4
4
SELECT"SocialSourceNetworkID", "RegionID", COUNT(*), AVG("Age"), AVG("ParamPrice"), STDDEV("ParamPrice") as s, VAR("ParamPrice") FROM hits GROUP BY"SocialSourceNetworkID", "RegionID"HAVING s IS NOT NULLORDER BY s DESCLIMIT10;
5
5
SELECT"ClientIP", "WatchID", COUNT(*) c, MIN("ResponseStartTiming") tmin, MEDIAN("ResponseStartTiming") tmed, MAX("ResponseStartTiming") tmax FROM hits WHERE"JavaEnable"=0GROUP BY"ClientIP", "WatchID"HAVING c >1ORDER BY tmed DESCLIMIT10;
6
-
SELECT"ClientIP", "WatchID", COUNT(*) c, MIN("ResponseStartTiming") tmin, APPROX_PERCENTILE_CONT("ResponseStartTiming", 0.95) tp95, MAX("ResponseStartTiming") tmax FROM'hits'WHERE"JavaEnable"=0GROUP BY"ClientIP", "WatchID"HAVING c >1ORDER BY tp95 DESCLIMIT10;
6
+
SELECT"ClientIP", "WatchID", COUNT(*) c, MIN("ResponseStartTiming") tmin, APPROX_PERCENTILE_CONT("ResponseStartTiming", 0.95) tp95, MAX("ResponseStartTiming") tmax FROM'hits'WHERE"JavaEnable"=0GROUP BY"ClientIP", "WatchID"HAVING c >1ORDER BY tp95 DESCLIMIT10;
7
+
SELECTCOUNT(*) AS ShareCount FROM hits WHERE"IsMobile"=1AND"MobilePhoneModel"LIKE'iPhone%'AND"SocialAction"='share'AND"SocialSourceNetworkID"IN (5, 12) AND"ClientTimeZone" BETWEEN -5AND5AND regexp_match("Referer", '\/campaign\/(spring|summer)_promo') IS NOT NULLAND CASE WHEN split_part(split_part("URL", 'resolution=', 2), '&', 1) ~ '^\d+$' THEN split_part(split_part("URL", 'resolution=', 2), '&', 1)::INT ELSE 0 END >1920AND levenshtein("UTMSource", "UTMCampaign") <3;
0 commit comments