Preload path locks for TreeSummary
What does this MR do?
Preload path locks for entry paths to avoid N + 1 request:
Before:
PathLock Load (0.5ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = 'app' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '1.rb' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '1.txt' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '10.txt' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '101.txt' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '102.txt' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '103.txt' LIMIT 1
PathLock Load (0.2ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 21 AND "path_locks"."path" = '104.txt' LIMIT 1
...
After:
PathLock Load (0.3ms) SELECT "path_locks".* FROM "path_locks" WHERE "path_locks"."project_id" = 2 AND "path_locks"."path" IN (
'app', '1.rb', '1.txt', '10.txt', '101.txt', '102.txt', '103.txt', '104.txt', '105.txt', '106.txt', '107.txt', '108.txt',
'109.txt', '11.txt', '110.txt', '111.txt', '113.txt', '114.txt', '115.txt', '116.txt', '117.txt', '118.txt', '119.txt', '12.txt',
'120.txt', '.gitlab', 'bin', 'cmd', 'hooks', 'internal', 'spec', 'support', '.codeclimate.yml', '.gitignore', '.gitlab-ci.yml',
'.rubocop.yml', '.ruby-version', 'CHANGELOG', 'CONTRIBUTING.md', 'Gemfile', 'Gemfile.lock', 'LICENSE', 'Makefile', 'README.md',
'VERSION', 'config.yml.example', 'go.mod', 'go.sum')
Related issues:
Edited by Igor Drozdov