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

Fix Slow Query #419

Open
retroinspect opened this issue Sep 21, 2023 · 0 comments · Fixed by #414
Open

Fix Slow Query #419

retroinspect opened this issue Sep 21, 2023 · 0 comments · Fixed by #414
Assignees
Labels
bug Something isn't working

Comments

@retroinspect
Copy link
Contributor

retroinspect commented Sep 21, 2023

Sentry에 제보된 Slow Query 2종을 해결한다

문제의 쿼리1

SELECT `core_article`.`id`, `core_article`.`created_at`, `core_article`.`updated_at`,
  `core_article`.`deleted_at`, `core_article`.`title`, `core_article`.`content`,
  `core_article`.`content_text`, `core_article`.`name_type`, `core_article`.`is_content_sexual`,
  `core_article`.`is_content_social`, `core_article`.`hit_count`, `core_article`.`comment_count`,
  `core_article`.`report_count`, `core_article`.`positive_vote_count`,
  `core_article`.`negative_vote_count`, `core_article`.`migrated_hit_count`,
  `core_article`.`migrated_positive_vote_count`, `core_article`.`migrated_negative_vote_count`,
  `core_article`.`created_by_id`, `core_article`.`parent_topic_id`, `core_article`.`parent_board_id`,
  `core_article`.`commented_at`, `core_article`.`url`, `core_article`.`content_updated_at`,
  `core_article`.`hidden_at`, `core_article`.`topped_at`
FROM `core_article`
WHERE (
  `core_article`.`deleted_at` = '0001-01-01 00:00:00.000000' AND
  `core_article`.`parent_board_id` = 1
)
ORDER BY `core_article`.`created_at` DESC
LIMIT 1

문제의 쿼리2

SELECT COUNT(*) AS `__count`
FROM `core_article`
WHERE (
  `core_article`.`deleted_at` = '0001-01-01 00:00:00.000000' AND NOT (`core_article`.`created_by_id` IN (
    SELECT U0.`user_id`
    FROM `core_block` U0
    WHERE (
      U0.`deleted_at` = '0001-01-01 00:00:00.000000' AND U0.`blocked_by_id` = 1
    )
  ) AND `core_article`.`name_type` = 1)
)
@retroinspect retroinspect self-assigned this Sep 21, 2023
@retroinspect retroinspect linked a pull request Sep 21, 2023 that will close this issue
@injoonH injoonH added the bug Something isn't working label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants