Project

General

Profile

« Previous | Next » 

Revision 6947

use a temporary table to calculate the maximum revision for a given docid and use that when setting the accessfileid during upgrade. the query plan for the all-in-one statement must be brutal as it's been running for 4 hours at this point....

View differences:

upgrade-db-to-2.0.0-oracle.sql
117 117
 * Update the accessfileid to use guid
118 118
 * NOTE: uses the last revision's guid as the new accessfileid
119 119
 */
120
CREATE TABLE max_identifier (guid VARCHAR2(2000), docid VARCHAR2(250), rev NUMBER(8));
121

  
122
/** insert the max rev identifier for each document **/
123
INSERT INTO max_identifier (docid, rev, guid)
124
SELECT docid, MAX(rev), docid || '.' || MAX(rev)
125
FROM identifier
126
GROUP BY docid
127

  
128
/** only need to join on docid since there is a single row for the max docid **/
120 129
UPDATE xml_access
121
SET accessfileid = id.guid
122
FROM identifier id, xml_access xa
123
WHERE xa.accessfileid = id.docid
124
AND id.rev = 
125
	(SELECT MAX(id2.rev) FROM identifier id2 WHERE id.docid = id2.docid);
130
SET accessfileid = maxid.guid
131
FROM max_identifier maxid, xml_access xa
132
WHERE xa.accessfileid = maxid.docid
133
AND xa.guid IS NOT null
126 134

  
135
DROP TABLE max_identifier;
136

  
127 137
/**
128 138
 * Remove old access rules
129 139
 */

Also available in: Unified diff