hard
Advanced Query Optimization
Analyze and optimize a highly inefficient SQL query for a large dataset.
📝 Contenu du Prompt
Given a scenario with a table 'User_Activities' containing 50 million rows and columns (user_id, activity_type, timestamp, metadata), write an optimized query to find the top 10 users who performed the specific sequence of actions 'Login' -> 'View_Product' -> 'Purchase' within a 30-minute window at least 5 times in the last month. Explain your indexing strategy, join logic, and how you would handle window functions to optimize execution time. Additionally, provide the EXPLAIN ANALYZE output interpretation for your proposed solution.