Skip to content

Commit eeaec83

Browse files
author
Callum McIntyre
committed
[CA-271014] Reduce Database calls in get_all_plugged_srs
Replace the database calls for each PBD to get its currently_attached with a single call using `get_refs_where` to get only the currently attached PBDs. Signed-off-by: Callum McIntyre <[email protected]>
1 parent aee113c commit eeaec83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ocaml/xapi/helpers.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,8 @@ let i_am_srmaster ~__context ~sr =
10121012
get_srmaster ~__context ~sr = get_localhost ~__context
10131013

10141014
let get_all_plugged_srs ~__context =
1015-
let pbds = Db.PBD.get_all ~__context in
1016-
let pbds_plugged_in = List.filter (fun self -> Db.PBD.get_currently_attached ~__context ~self) pbds in
1015+
let pbds_plugged_in = Db.PBD.get_refs_where ~__context ~expr:(
1016+
Eq (Field "currently_attached", Literal "true")) in
10171017
List.setify (List.map (fun self -> Db.PBD.get_SR ~__context ~self) pbds_plugged_in)
10181018

10191019
let get_all_plugged_srs_local ~__context =

0 commit comments

Comments
 (0)