JBAS-826 Record hold counts for bib-level only
authorBill Erickson <berickxx@gmail.com>
Mon, 22 May 2017 18:21:05 +0000 (14:21 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Modify the holds-per-record counting code to only look at title-level
holds, for now anyway.  This is makes the query a lot faster, which
is a concern given that we still see several million API calls to
open-ils.circ.bre.holds.count per day.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 2cb5cb9..2493890 100644 (file)
@@ -4306,47 +4306,51 @@ sub rec_hold_count {
             '+ahr' => {
                 cancel_time => undef,
                 fulfillment_time => undef,
-                '-or' => [
-                    {
-                        '-and' => {
-                            hold_type => [qw/C F R/],
-                            target => {
-                                in => {
-                                    select => {acp => ['id']},
-                                    from => { acp => $cn_join }
-                                }
-                            }
-                        }
-                    },
-                    {
-                        '-and' => {
-                            hold_type => 'V',
-                            target => {
-                                in => {
-                                    select => {acn => ['id']},
-                                    from => {acn => $bre_join}
-                                }
-                            }
-                        }
-                    },
-                    {
-                        '-and' => {
-                            hold_type => 'P',
-                            target => {
-                                in => {
-                                    select => {bmp => ['id']},
-                                    from => {bmp => $bre_join}
-                                }
-                            }
-                        }
-                    },
-                    {
-                        '-and' => {
-                            hold_type => 'T',
-                            target => $target_id
-                        }
-                    }
-                ]
+# KCLS JBAS-826 -- make the record hold counts query faster by only
+# counting bib-level holds (which represent >99% of KCLS' holds).
+                hold_type => 'T',
+                target => $target_id
+#                '-or' => [
+#                    {
+#                        '-and' => {
+#                            hold_type => [qw/C F R/],
+#                            target => {
+#                                in => {
+#                                    select => {acp => ['id']},
+#                                    from => { acp => $cn_join }
+#                                }
+#                            }
+#                        }
+#                    },
+#                    {
+#                        '-and' => {
+#                            hold_type => 'V',
+#                            target => {
+#                                in => {
+#                                    select => {acn => ['id']},
+#                                    from => {acn => $bre_join}
+#                                }
+#                            }
+#                        }
+#                    },
+#                    {
+#                        '-and' => {
+#                            hold_type => 'P',
+#                            target => {
+#                                in => {
+#                                    select => {bmp => ['id']},
+#                                    from => {bmp => $bre_join}
+#                                }
+#                            }
+#                        }
+#                    },
+#                    {
+#                        '-and' => {
+#                            hold_type => 'T',
+#                            target => $target_id
+#                        }
+#                    }
+#                ]
             }
         }
     };