Select distinct … inner join vs. select … where id in (…)

前端 未结 3 1330
甜味超标
甜味超标 2021-01-19 12:58

I\'m trying to create a subset of a table (as a materialized view), defined as those records which have a matching record in another materialized view.

For example,

3条回答
  •  半阙折子戏
    2021-01-19 13:42

    This will depend on the data you have, but using Distinct within the join could improve your performance:

    Select u.*
    From Users u
    Join ( Select Distinct user_id
           From log_mview ) l On u.user_id = l.user_id
    

提交回复
热议问题