Life is Really Short, Have Your Life!!

ござ先輩の主に技術的なメモ

HerokuのJawsDBでmax_questions error

Herokuで借りているMySQL(JawsDB)で、2万件弱のSQLを発行する処理(データの一括登録)を投げてしまったら、以下のエラーが出た。

"User 'hogehogehoge' has exceeded the 'max_questions' resource (current value: 18000)")

devcenter.heroku.com

sharedプランの安いインスタンスなので、 1時間あたりに実行可能なクエリの数を超えてしまった模様。困ったことにこのエラーを踏んでしまうと、1時間経過しないとリセットされず、一切のSQLが実行できなくなってしまう。実質ダウンだよね。ドキュメントに明言されている。

The ‘max_questions’ value is a limit that is placed on shared plan accounts to help preserve computing power for other shared plan users on the same server. It is essentially a limit on the number of queries that can be executed from that account in an hour. After 1 hour of reaching the limit, the limit will be reset and queries can again be executed.

After 1 hour of reaching the limit, the limit will be reset and queries can again be executed.

なるほどね。

大量のSQLを投げる必要がある場合、1つのクエリにまとめないとだめだな。SQLAlchemyでadd_allしたとしても、SQL文がリストの数だけ作られるっぽい。MySQLクライアントとかで流し込んだほうが確実だが、それでいいのか俺。