Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update problemset.php #972

Merged
merged 7 commits into from
Oct 4, 2023
Merged

Update problemset.php #972

merged 7 commits into from
Oct 4, 2023

Conversation

Andy-qinyuhai
Copy link

优化翻页问题

优化翻页问题
@zhblue
Copy link
Owner

zhblue commented Oct 3, 2023

$sql = "SELECT problem_id,result FROM solution WHERE user_id=? ";
系统里可能有数百万条提交,其中属于当前用户的可达几千条甚至上万条,这个可能会影响性能。
宁可查两遍distinct

@Andy-qinyuhai
Copy link
Author

确实... 没注意到同一个用户有这么多条提交记录,如果 result 不小于 4 的话,或许可以写成这样:SELECT problem_id, MIN(result) AS min_result FROM solution WHERE user_id=? GROUP BY problem_id

@zhblue
Copy link
Owner

zhblue commented Oct 3, 2023

好像可以,你先用一段时间看看,有没有别的问题。

@zhblue zhblue merged commit 360fbc4 into zhblue:master Oct 4, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants