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

feat(server): load face entities faster #5281

Merged
merged 1 commit into from Nov 24, 2023

Conversation

l0nax
Copy link
Contributor

@l0nax l0nax commented Nov 23, 2023

The added indices are based on monitoring a server with

  • 6 users
  • 120.000+ Pictures
  • 500+ GiB Storage

Especially the query executed when loading the peoples' page gains a speedup of 4x.

@zackpollard
Copy link
Contributor

These indexes should be managed inside the typeorm schema. Take a look at the following docs from TypeORM, you can create the indexes using the schema and have it automatically generate the migration file for you. https://orkhan.gitbook.io/typeorm/docs/indices

@l0nax l0nax force-pushed the add-face-asset-indicies branch 2 times, most recently from 94142c6 to 4fb2fed Compare November 23, 2023 15:12
@l0nax l0nax requested a review from martabal November 23, 2023 15:16
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Is there a way to have postgres show the slowest x queries? It would be cool to see what those are on a large instance.

The query executed when loading the "People" page joins, among others, over "personId".
The added indices improve the overall performance of those JOIN queries.

Additionally, one ORDER BY clause is dropped since the resulting values
will always be TRUE, and thus, sorting them does not change the result.
@l0nax
Copy link
Contributor Author

l0nax commented Nov 23, 2023

@jrasm91 there are many ways to monitor your PostgreSQL instance.

You could use, e.g., the pg_stat_statements extension.
Postgres can even generate execution plans for slow queries automatically (see https://www.postgresql.org/docs/current/auto-explain.html).

@l0nax l0nax requested a review from martabal November 23, 2023 18:53
@davidpan
Copy link

Thanks for the PR! Is there a way to have postgres show the slowest x queries? It would be cool to see what those are on a large instance.

For development and testing, you can use pg_stat_statements.
link: https://www.postgresql.org/docs/current/pgstatstatements.html

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jrasm91 jrasm91 enabled auto-merge (squash) November 24, 2023 14:35
@jrasm91 jrasm91 merged commit 309be88 into immich-app:main Nov 24, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants