Fix high CPU usage with overboard's catalog #134

Open
Zankaria wants to merge 8 commits from ukko-catalog-sql-perf into config
Owner
No description provided.
Author
Owner

Right now it errors with

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH thread_data AS ( SELECT id AS thread_id,COUNT(id) A...' at line 1

Right now it errors with > SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH thread_data AS ( SELECT id AS thread_id,COUNT(id) A...' at line 1
Zankaria force-pushed ukko-catalog-sql-perf from 258e873706 to 9821a7420d 2025-07-06 16:18:40 -05:00 Compare
Author
Owner

The query has a huge problem: it only counts the images in the OP

The query has a huge problem: it only counts the images in the OP
Author
Owner

Currently the query at 33af676a8d is correct in isolation, however when used with the rest of the code, it causes a syntax error. Needs more investigation.

Currently the query at 33af676a8d172694ebae0df17e3b0723b51c0ca9 is correct in isolation, however when used with the rest of the code, it causes a syntax error. Needs more investigation.
Author
Owner

As an additional idea: we should limit each posts_* subquery to the maximum number of posts the the overboard catalog will display

As an additional idea: we should limit each posts_* subquery to the maximum number of posts the the overboard catalog will display
Author
Owner

Issue seems to stem from vichan using A FUCKING REGEX to append the limit to the generated query.
Should be solved by using implode to generate the unified query and then append the limit.

Issue seems to stem from vichan using **A FUCKING REGEX** to append the limit to the generated query. Should be solved by using implode to generate the unified query and then append the limit.
Zankaria force-pushed ukko-catalog-sql-perf from a0c44eeb08 to 3db5c3c094 2025-07-11 17:04:45 -05:00 Compare
Zankaria force-pushed ukko-catalog-sql-perf from 3db5c3c094 to ec85705fb2 2025-07-11 17:08:44 -05:00 Compare
Author
Owner

So, mariadb doesn't seem to support in subqueries all the things that speed up the query...

So, mariadb doesn't seem to support in subqueries all the things that speed up the query...
Author
Owner

Good news: we now almost sort-of semi have the code to distinguish which DB type we're running on.
We can run this only if we're using MySQL😁

Good news: we now almost sort-of semi have the code to distinguish which DB type we're running on. We can run this only if we're using MySQL😁
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin ukko-catalog-sql-perf:ukko-catalog-sql-perf
git switch ukko-catalog-sql-perf

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch config
git merge --no-ff ukko-catalog-sql-perf
git switch ukko-catalog-sql-perf
git rebase config
git switch config
git merge --ff-only ukko-catalog-sql-perf
git switch ukko-catalog-sql-perf
git rebase config
git switch config
git merge --no-ff ukko-catalog-sql-perf
git switch config
git merge --squash ukko-catalog-sql-perf
git switch config
git merge --ff-only ukko-catalog-sql-perf
git switch config
git merge ukko-catalog-sql-perf
git push origin config
Sign in to join this conversation.
No reviewers
No labels
Bug
Proposal
Request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
leftypol/leftypol!134
No description provided.