From 582d2397004b8a55847a3fe933cc29e8b99ab8f6 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 19 Aug 2018 18:31:09 -0700 Subject: add hints for postgres query planner --- rust/src/api_server.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rust/src/api_server.rs') diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index f7866b68..9239d63b 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -318,6 +318,9 @@ impl Server { let (ident, rev): (ContainerIdentRow, ContainerRevRow) = container_ident::table .inner_join(container_rev::table) .filter(container_rev::issnl.eq(issnl)) + // This NOT NULL is here to ensure the postgresql query planner that it can use an + // index + .filter(container_rev::issnl.is_not_null()) .filter(container_ident::is_live.eq(true)) .filter(container_ident::redirect_id.is_null()) .first(conn)?; @@ -344,6 +347,9 @@ impl Server { let (ident, rev): (CreatorIdentRow, CreatorRevRow) = creator_ident::table .inner_join(creator_rev::table) .filter(creator_rev::orcid.eq(orcid)) + // This NOT NULL is here to ensure the postgresql query planner that it can use an + // index + .filter(creator_rev::orcid.is_not_null()) .filter(creator_ident::is_live.eq(true)) .filter(creator_ident::redirect_id.is_null()) .first(conn)?; -- cgit v1.2.3