various speed improvements to the collectionHQ extract
authorGalen Charlton <gmc@esilibrary.com>
Thu, 27 Sep 2012 21:43:13 +0000 (17:43 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 27 Sep 2012 21:49:34 +0000 (17:49 -0400)
commitbc33383f00199eec6559f47706d36415c2c2000f
tree6ae59f4b06c6bfc126b55162739971f6f5be9bf0
parentd2b95577fe03ea651e6a2ee57b8b941e68d1cdf7
various speed improvements to the collectionHQ extract

This is the result of a first pass to remove inefficient
queries on metabib.real_full_rec and auditor.asset_copy_history.

Most of the changes don't affect the output, but there are a
couple exceptions:

- the new version is more likely to pick the first 082$a
  for the class number (which is also more correct)
- the script now bases the "current use count" on the date that
  the item was last transited to the current circ lib, rather than
  the date the circ lib simply changed.

The last change is the most uncertain.  One the one hand, it helps
proof the extract against pruning of the asset.copy auditor table.
On the other hand, if items change their circ library without getting
formally transited (which might be theoretically possible for
some workflows) the current use count *might* be calculated
differently than expected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
collectionHQ/functions.sql