我有类似如下的表结构:可伸缩的方式与许多加入了许多表
user
id
name
profile_stat
id
name
profile_stat_value
id
name
user_profile
user_id
profile_stat_id
profile_stat_value_id
我的问题是:
如何评估一个查询,我想找到所有有多个统计信息的用户有profile_stat_id和profile_stat_value_id?
我试过做一个内部自我加入,但是当搜索许多统计信息时,它很快就会变得疯狂。我也试着对实际的user_profile表进行计数,这样会更好,但仍然很慢。
有一些神奇的我失踪?我在user_profile表中有大约1000万行,并且希望查询不超过几秒钟。那可能吗?