(
                  
                  
                      select story_id, count(*) as count, type
                  
                  
                      from story_statuses
                  
                  
                      where type = ? and removed_at is null
                  
                  
                      group by story_id, type
                  
                  
                      limit 5
                  
                  
                    )
                  
                  
                    select id, title, count, type
                  
                  
                    from top
                  
                  
                    join stories on top.story_id = stories.id;
                  
                  
                  
                  
                  
                  Должен ли я накладывать индекс на type и removed_at?
                  
                  
                
А где тут topN? Я не вижу ORDER BY в CTE...
Обсуждают сегодня