Facebook Search Sessions That End in a Result Click
Last updated: November 29, 2026
Quick Overview
Group each user's Facebook Search queries into search sessions (a new session after five minutes without a query or click), then report the share of search sessions that ended with a result click and the average number of queries per session.
Meta
November 29, 20260
0
0 solved
Group each user's Facebook Search queries into search sessions (a new session after five minutes without a query or click), then report the share of search sessions that ended with a result click and the average number of queries per session.
A search-quality SQL problem in the style of Meta's onsite data science interviews. The interviewer looks for sessionization on mixed event types, a success definition based on the final event, and an understanding that reformulations signal a failed first query.
What the Interviewer Expects
- Sessionizes queries and clicks together with a five-minute gap
- Defines success as the last event of the session being a click
- Counts queries per session to capture reformulation
- Aggregates to session-level metrics
- Explains why session success beats per-query CTR for search
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you detect reformulations that are just typo fixes?
- Why could a session with no click still be a success, for example on a profile card?
- How would you split the metric by query type such as people, groups, or Marketplace?
- How would you use this metric as a guardrail in a ranking test?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
search_log(user_id, event_type, event_ts) where event_type is query or result_click. A search session breaks after five minutes with no event. A session is successful if its final event is a c...
Approach
Use LAG and a running sum to assign session numbers over both event types. Then per session, take the last event with ROW_NUMBER descending, and count queries with a conditional sum. Finally avera...