redo ALL metarecords with the quick-loader
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Apr 2005 21:40:08 +0000 (21:40 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Apr 2005 21:40:08 +0000 (21:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@541 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/src/extras/import/quick_metarecord_map.sql [new file with mode: 0644]

diff --git a/Evergreen/src/extras/import/quick_metarecord_map.sql b/Evergreen/src/extras/import/quick_metarecord_map.sql
new file mode 100644 (file)
index 0000000..9094ab6
--- /dev/null
@@ -0,0 +1,25 @@
+BEGIN;
+
+ALTER TABLE metabib.metarecord_source_map DROP CONSTRAINT metabib_metarecord_source_map_metarecord_fkey;
+
+TRUNCATE metabib.metarecord;
+TRUNCATE metabib.metarecord_source_map;
+
+INSERT INTO metabib.metarecord (fingerprint,master_record)
+       SELECT  fingerprint,min(id)
+         FROM  biblio.record_entry
+         WHERE fingerprint IS NOT NULL
+         GROUP BY 1;
+
+INSERT INTO metabib.metarecord_source_map (metarecord,source)
+       SELECT  m.id, b.id
+         FROM  biblio.record_entry b
+               JOIN metabib.metarecord m ON (m.fingerprint = b.fingerprint);
+
+ALTER TABLE metabib.metarecord_source_map ADD CONSTRAINT metabib_metarecord_source_map_metarecord_fkey FOREIGN KEY (metarecord) REFERENCES metabib.metarecord (id);
+
+COMMIT;
+
+VACUUM FULL ANALYZE VERBOSE metabib.metarecord;
+VACUUM FULL ANALYZE VERBOSE metabib.metarecord_source_map;
+