From cd439d261c99f1e51cb86e9ae9442b1ade0a6bd7 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 18 Mar 2019 23:59:11 -0700 Subject: [PATCH] comment out suboptimal pg query --- store/repos/repos.go | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/store/repos/repos.go b/store/repos/repos.go index 952a7064..c6f534d1 100644 --- a/store/repos/repos.go +++ b/store/repos/repos.go @@ -432,21 +432,21 @@ WHERE repo_id = :repo_id ` const queryRepoWithBuild = queryColsBulds + ` -FROM repos LEFT OUTER JOIN builds ON build_id = ( - SELECT build_id FROM builds - WHERE builds.build_repo_id = repos.repo_id - ORDER BY build_id DESC - LIMIT 1 -) +FROM repos LEFT OUTER JOIN builds ON build_id = repo_counter INNER JOIN perms ON perms.perm_repo_uid = repos.repo_uid WHERE perms.perm_user_id = :user_id ORDER BY repo_slug ASC; ` -// OPTIMIZED QUERY: -// FROM repos LEFT OUTER JOIN builds ON build_id = repo_counter +// const queryRepoWithBuild = queryColsBulds + ` +// FROM repos LEFT OUTER JOIN builds ON build_id = ( +// SELECT build_id FROM builds +// WHERE builds.build_repo_id = repos.repo_id +// ORDER BY build_id DESC +// LIMIT 1 +// ) // INNER JOIN perms ON perms.perm_repo_uid = repos.repo_uid -// WHERE perms.perm_user_id = 2 +// WHERE perms.perm_user_id = :user_id // ORDER BY repo_slug ASC; const queryRepoWithBuildAll = queryColsBulds + ` @@ -470,12 +470,3 @@ WHERE EXISTS ( ORDER BY build_id DESC LIMIT 50; ` - -// const queryRepoWithBuildIncompleteOld = queryColsBulds + ` -// FROM repos -// INNER JOIN perms ON perms.perm_repo_uid = repos.repo_uid -// INNER JOIN builds ON builds.build_repo_id = repos.repo_id -// WHERE builds.build_status IN ('pending', 'running') -// ORDER BY build_id DESC -// LIMIT 50; -// `