Skip to content

Index: Improve the query performance when flagging hidden files #2928

Description

@jerome-cui

I noticed that there is a SQL query causes the CPU to 100% usage all the time, below is the information I found in db slow log:

# Time: 221120 17:13:36
# User@Host: photoprism[photoprism] @  [172.24.0.2]
# Thread_id: 392  Schema: photoprism  QC_hit: No
# Query_time: 6288.676700  Lock_time: 0.000035  Rows_sent: 0  Rows_examined: 1836237798
# Rows_affected: 0  Bytes_sent: 0
SET timestamp=1668935616;
UPDATE `photos` SET `photo_quality` = -1  WHERE (id NOT IN (SELECT photo_id FROM files WHERE file_primary = 1 AND file_missing = 0 AND file_error = '' AND deleted_at IS NULL));

This maybe the issue of Mariadb because it works with this query "select count(*) from photos WHERE (id NOT IN (SELECT photo_id FROM files WHERE file_primary = 1 AND file_missing = 0 AND file_error = '' AND deleted_at IS NULL))", but how could I avoid this issue in Photoprism?

Database: Mariadb 10.9.3.
Row count of table 'photos': 86789.

Metadata

Metadata

Assignees

Labels

releasedAvailable in a stable release

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Release 🌈

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions