Skip to content

Commit 2f37270

Browse files
committed
Fixed long-query in generating Archive feed
This addresses a problem with a query used to generate the archival feed read by Merritt (repository). The query performed very badly. It wasn't easy to notice until the Merritt made requests pretty far into the list of resources to be accessioned. It turns out the query wasn't using the correct index and so it was taking about 2 seconds to execute. Given the other traffic Open Context responds to, these 2 second delays started adding up, causing some tables to lock and others to crash entirely. The query is now forced use the appropriate index, the WHERE condition also seems to help speed things up.
1 parent 51d8cfb commit 2f37270

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

application/models/ArchiveFeed.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,15 @@ function get_entries(){
430430
$db = $this->db;
431431

432432
if(!$this->itemType){
433-
$whereCondition = true;
433+
$whereCondition = "ItemUpdated >= '1969-01-01' ";
434434
}
435435
else{
436436
$whereCondition = " itemType = '".$this->itemType."' ";
437437
}
438438

439439
$sql = "SELECT *
440440
FROM noid_bindings
441+
FORCE INDEX ( updated )
441442
WHERE ".$whereCondition."
442443
ORDER BY ItemUpdated DESC
443444
LIMIT ".($this->recStart ).",".self::entriesPerPage."

0 commit comments

Comments
 (0)