From 657c1e7d4d6f07762bc1f6a7b24e9512e0089987 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 19 Aug 2018 18:42:21 -0700 Subject: add NOT NULL to other lookups --- rust/src/api_server.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rust') diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index 9239d63b..66e6359a 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -396,6 +396,9 @@ impl Server { let (ident, rev): (FileIdentRow, FileRevRow) = file_ident::table .inner_join(file_rev::table) .filter(file_rev::sha1.eq(sha1)) + // This NOT NULL is here to ensure the postgresql query planner that it can use an + // index + .filter(file_rev::sha1.is_not_null()) .filter(file_ident::is_live.eq(true)) .filter(file_ident::redirect_id.is_null()) .first(conn)?; @@ -434,6 +437,9 @@ impl Server { let (ident, rev): (ReleaseIdentRow, ReleaseRevRow) = release_ident::table .inner_join(release_rev::table) .filter(release_rev::doi.eq(doi)) + // This NOT NULL is here to ensure the postgresql query planner that it can use an + // index + .filter(release_rev::doi.is_not_null()) .filter(release_ident::is_live.eq(true)) .filter(release_ident::redirect_id.is_null()) .first(conn)?; -- cgit v1.2.3