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

SELECT * FROM messages WHERE user_id ORDER BY created_at DESC LIMIT N が非常に遅い #2425

Open
pikachu0310 opened this issue May 16, 2024 · 0 comments
Labels
kind/bug バグや機能不全に関するもの kind/performance パフォーマンスの問題に関するもの

Comments

@pikachu0310
Copy link
Contributor

5/9 に、このクエリが12回たたかれ、それぞれが10分くらい探索し続け、DBのCPU使用率が張り付き、traQがめちゃくちゃ重くなった。
おそらくIndexが効いていないだけだが、このクエリがなんで叩かれたのか、から調査してIndexを貼るか他の解決法を模索するかをして欲しい。

{"id":"8cac9a5f-a291-4b7e-a2d4-71134508c598","state":1,"bot":true,"iconFileId":"cd7d0d0d-18d3-434b-a369-54077323f3a3","displayName":"光の商人 カシワデ","name":"Webhook#jKyaX6KRS36i1HETRQjFmA","twitterId":"","lastOnline":null,"updatedAt":"2024-05-09T07:46:05.612726Z","tags":[],"groups":[],"bio":"","homeChannel":null}

SELECT * FROM messagesWHERE messages.user_id = 'UUID' ANDmessages.deleted_at IS NULL ORDER BY messages.created_at DESC LIMIT N
https://monitor.trap.jp/d/HU1s_0w7z/mariadb-slow-query-log?orgId=1&from=1715239500000&to=1715241900000
https://github.com/traPtitech/traQ/blob/master/docs/dbSchema/messages.md

https://q.trap.jp/messages/6a0dbe52-4ec6-4581-94db-8a106d13ef2b

@pikachu0310 pikachu0310 added kind/bug バグや機能不全に関するもの kind/performance パフォーマンスの問題に関するもの labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug バグや機能不全に関するもの kind/performance パフォーマンスの問題に関するもの
Projects
None yet
Development

No branches or pull requests

1 participant