Database performance optimization for large quantities

- Add two indices for avoiding possible slow queries

> This is an experimental handle for the database which has some tables over one hundred thousand lines.
This commit is contained in:
Lost-MSth
2022-08-29 22:41:31 +08:00
parent 12cd187563
commit 7bf43c3e07
3 changed files with 24 additions and 17 deletions

View File

@@ -52,15 +52,17 @@ def download(file_path):
with Connect() as c:
try:
x = UserDownload(c)
x.file_path = file_path
x.select_from_token(request.args.get('t'))
x.token = request.args.get('t')
x.song_id, x.file_name = file_path.split('/', 1)
x.select_for_check()
if x.is_limited:
raise ArcError('You have reached the download limit.', 903)
if x.is_valid:
x.insert_user_download()
return send_from_directory(Constant.SONG_FILE_FOLDER_PATH, file_path, as_attachment=True, conditional=True)
except ArcError as e:
app.logger.warning(format_exc())
if Config.ALLOW_WARNING_LOG:
app.logger.warning(format_exc())
return error_return(e)
return error_return()