From: Enrico Tassi Date: Mon, 11 Jul 2005 14:07:04 +0000 (+0000) Subject: tentative hack for the incredible DB slowdown. X-Git-Tag: pre_notation~45 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=c1554e961d5147b8fde7c47d783603d77fe4576c;p=helm.git tentative hack for the incredible DB slowdown. I suppose we use the DB in a really uncommon way, billions of inserts and queryes mixed, while (I suppose) the usual is a bunch of inserts and then billions of queries. ANALYZE TABLE is called sometime to try to ameliorate this problem. --- diff --git a/helm/ocaml/metadata/metadataDb.ml b/helm/ocaml/metadata/metadataDb.ml index 51b432a4f..f18787e83 100644 --- a/helm/ocaml/metadata/metadataDb.ml +++ b/helm/ocaml/metadata/metadataDb.ml @@ -138,7 +138,7 @@ let already_indexed _ = false let index_constant ~dbd = let query = prepare_insert () in fun ~uri ~body ~ty -> - if not (already_indexed uri) then begin + if not (already_indexed uri) then beginrel_tbl () let name = UriManager.name_of_uri uri in let uri = UriManager.string_of_uri uri in let metadata = MetadataExtractor.compute ~body ~ty in @@ -162,8 +162,24 @@ let index_inductive_def ~dbd = List.iter (fun (uri, name, _) -> insert_name ~dbd ~uri ~name) metadata end *) + +(***** TENTATIVE HACK FOR THE DB SLOWDOWN - BEGIN *******) +let analyze_index = ref 0 +let eventually_analyze dbd = + incr analyze_index; + if !analyze_index > 30 then + begin + let analyze t = "ANALYZE TABLE " ^ t ^ ";" in + List.iter + (fun table -> ignore (Mysql.exec dbd (analyze table))) + [name_tbl (); rel_tbl (); sort_tbl (); obj_tbl(); count_tbl()] + end + +(***** TENTATIVE HACK FOR THE DB SLOWDOWN - END *******) + let index_obj ~dbd ~uri = if not (already_indexed uri) then begin + eventually_analyze dbd; let metadata = MetadataExtractor.compute_obj uri in let uri_of (a,b,c) = (a,c) in let uri = UriManager.string_of_uri uri in