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

Slow SQL Instance Queries with Large Jobs Table #1353

Open
MCterra10 opened this issue Dec 22, 2021 · 1 comment
Open

Slow SQL Instance Queries with Large Jobs Table #1353

MCterra10 opened this issue Dec 22, 2021 · 1 comment
Labels
Backlog Issue to be scheduled for addressing Bug Something's fucky HTTP API The JSON Web API that controls the server Migration Requires or performs a database migration Reproduction Required Reproduction steps required for issue
Milestone

Comments

@MCterra10
Copy link

MCterra10 commented Dec 22, 2021

Describe the bug
Queries for details on server instances take a significant (>10 seconds) amount of time to complete.
Relevant slow queries log from MariaDB in logs section
Issue seems to be related to the ordering of the JOIN modifiers. I've had a similar issue when working with nfreader's statbus. The largest tables should be joined last to minimize processing, as joining large tables first expands the internal query table massively, creating processing delays for later joins, even if everything is eventually condensed for return.

To Reproduce
Steps to reproduce the behavior:

  1. Create a large amount of rows in the jobs table
  2. Connect to the control panel
  3. Notice that the data takes a very long time to retrieve

Expected behavior
The queries take a minimal amount of time to execute and the control panel is snappy when loading instance details. Workaround is manually clearing out the jobs table, but this is only a temp fix.

Logs

# Time: 211208  8:51:45
# User@Host: tgs[tgs] @ localhost [127.0.0.1]
# Thread_id: 45805  Schema: tgs4  QC_hit: No
# Query_time: 10.170102  Lock_time: 0.000658  Rows_sent: 0  Rows_examined: 4510242
# Rows_affected: 0  Bytes_sent: 2296
SET timestamp=1638921105;
SELECT `j`.`Id`, `j`.`CancelRight`, `j`.`CancelRightsType`, `j`.`Cancelled`, `j`.`CancelledById`, `j`.`Description`, `j`.`ErrorCode`, `j`.`ExceptionDetails`, `j`.`InstanceId`, `j`.`StartedAt`, `j`.`StartedById`, `j`.`StoppedAt`, `u`.`Id`, `u`.`CanonicalName`, `u`.`CreatedAt`, `u`.`CreatedById`, `u`.`Enabled`, `u`.`GroupId`, `u`.`LastPasswordUpdate`, `u`.`Name`, `u`.`PasswordHash`, `u`.`SystemIdentifier`, `u0`.`Id`, `u0`.`CanonicalName`, `u0`.`CreatedAt`, `u0`.`CreatedById`, `u0`.`Enabled`, `u0`.`GroupId`, `u0`.`LastPasswordUpdate`, `u0`.`Name`, `u0`.`PasswordHash`, `u0`.`SystemIdentifier`, `i0`.`Id`, `i0`.`AutoUpdateInterval`, `i0`.`ChatBotLimit`, `i0`.`ConfigurationType`, `i0`.`Name`, `i0`.`Online`, `i0`.`Path`, `i0`.`SwarmIdentifer`
FROM `Instances` AS `i`
INNER JOIN `Jobs` AS `j` ON `i`.`Id` = `j`.`InstanceId`
INNER JOIN `Users` AS `u` ON `j`.`StartedById` = `u`.`Id`
LEFT JOIN `Users` AS `u0` ON `u`.`CreatedById` = `u0`.`Id`
INNER JOIN `Instances` AS `i0` ON `j`.`InstanceId` = `i0`.`Id`
WHERE `i`.`SwarmIdentifer` IS NULL AND (`j`.`StoppedAt` IS NULL AND (`j`.`Description` LIKE 'Move instance ID %'));

Server State: (please complete the following information):

  • OS: Windows Server 2019 - v1809
  • Version: TGS 4 v4.15.7
  • Database Type/Version: MariaDB 10.6
  • BYOND Version Used: N/A
  • git Repository Used: austation/austation
  • Origin Commit hash Used: N/A
  • Active Test Merges: N/A
  • Client Version: .NET control panel v3.1.0.0

Additional context
N/A

@MCterra10 MCterra10 added Bug Something's fucky Reproduction Required Reproduction steps required for issue labels Dec 22, 2021
@Cyberboss Cyberboss added the Backlog Issue to be scheduled for addressing label Feb 15, 2022
@Cyberboss Cyberboss removed their assignment Feb 15, 2022
@Cyberboss Cyberboss added this to the Backlog milestone Feb 16, 2022
@Cyberboss
Copy link
Member

Easiest solution is to implement job codes to differentiate job types and then index those

@Cyberboss Cyberboss added HTTP API The JSON Web API that controls the server Migration Requires or performs a database migration labels Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backlog Issue to be scheduled for addressing Bug Something's fucky HTTP API The JSON Web API that controls the server Migration Requires or performs a database migration Reproduction Required Reproduction steps required for issue
Projects
None yet
Development

No branches or pull requests

2 participants