0

次のサブクエリにコメントアウトされた 2 行を含めると、Sybase 12.5 ASE サーバーが結果を取得するまでに時間がかかるようです。これらの 2 行がなければ、クエリは正常に実行されます。そのグループ化の何がそんなに間違っているのですか?

select days_played.day_played, count(distinct days_played.user_id) as OLD_users
from days_played inner join days_received
on days_played.day_played = days_received.day_received
and days_played.user_id = days_received.user_id
where days_received.min_bulk_MT > days_played.min_MO
and days_played.user_id in

(select sgia.user_id 
from days_played as sgia
where sgia.day_played < days_played.day_played
--group by sgia.user_id 
--having sum(sgia.B_first_msg) = 0
)

group by days_played.day_played
4

3 に答える 3

0

クエリを次のように書き直していただけますか。

select days_played.day_played,
       count(distinct days_played.user_id) as OLD_users
  from days_played
 inner join days_received on days_played.day_played = days_received.day_received
                         and days_played.user_id = days_received.user_id
 where days_received.min_bulk_MT > days_played.min_MO
   and 0 = (select sum(sgia.B_first_msg)
              from days_played as sgia
             where sgia.user_id = days_played.user_id
               and sgia.day_played < days_played.day_played
            )
 group by days_played.day_played

これでパフォーマンスが上がるといいのですが…

于 2009-10-16T10:55:01.227 に答える
0

showplan を使用して説明を表示し、クエリが何をするかを調べます。

この場合、サブクエリをメイン クエリの一部にして、サブクエリをなくすことはできませんか?

于 2009-10-16T10:48:18.300 に答える