From 7de6ee8e755b637fa5f0cf9c3130a9d8882ec994 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 10 Dec 2004 16:27:53 +0000 Subject: [PATCH] limiting the number of search term to 8. There was no limit before, but 8 words seems to be the upper limit mySQL can deal with (in less than a second. tested on a DB with 13 000 items) In 2.4, a new DB structure will highly speed things and this limit will be removed. FindDuplicate is activated again, the perf problems were due to this problem. --- C4/Biblio.pm | 23 ++++++++++++++--------- C4/SearchMarc.pm | 5 ++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 5f4aeaf2b9..ef527cbb63 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -292,13 +292,15 @@ sub MARCgettagslib { sub MARCfind_marc_from_kohafield { my ( $dbh, $kohafield,$frameworkcode ) = @_; return 0, 0 unless $kohafield; - my $sth = - $dbh->prepare( -"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?" - ); - $sth->execute($frameworkcode,$kohafield); - my ( $tagfield, $tagsubfield ) = $sth->fetchrow; - return ( $tagfield, $tagsubfield ); + my $relations = C4::Context->marcfromkohafield; + return ($relations->{$frameworkcode}->{$kohafield}->[0],$relations->{$frameworkcode}->{$kohafield}->[1]); +# my $sth = +# $dbh->prepare( +# "select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?" +# ); +# $sth->execute($frameworkcode,$kohafield); +# my ( $tagfield, $tagsubfield ) = $sth->fetchrow; +# return ( $tagfield, $tagsubfield ); } sub MARCfind_oldbiblionumber_from_MARCbibid { @@ -2525,8 +2527,6 @@ sub nsb_clean { sub FindDuplicate { my ($record)=@_; my $dbh = C4::Context->dbh; - # FIXME re-activate FindDuplicate - return; my $result = MARCmarc2koha($dbh,$record,''); # search duplicate on ISBN, easy and fast... my $sth = $dbh->prepare("select biblio.biblionumber,bibid,title from biblio,biblioitems,marc_biblio where biblio.biblionumber=biblioitems.biblionumber and marc_biblio.biblionumber=biblioitems.biblionumber and isbn=?"); @@ -2632,6 +2632,11 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.113 2004/12/10 16:27:53 tipaul +# limiting the number of search term to 8. There was no limit before, but 8 words seems to be the upper limit mySQL can deal with (in less than a second. tested on a DB with 13 000 items) +# In 2.4, a new DB structure will highly speed things and this limit will be removed. +# FindDuplicate is activated again, the perf problems were due to this problem. +# # Revision 1.112 2004/12/08 10:14:42 tipaul # * desactivate FindDuplicate # * fix from Genji diff --git a/C4/SearchMarc.pm b/C4/SearchMarc.pm index 12e9a39458..e4a4abf050 100644 --- a/C4/SearchMarc.pm +++ b/C4/SearchMarc.pm @@ -400,7 +400,10 @@ sub create_request { my $nb_active=0; # will contain the number of "active" entries. an entry is active if a value is provided. my $nb_table=1; # will contain the number of table. ++ on each entry EXCEPT when an OR is provided. - for(my $i=0; $i<=@$value;$i++) { + my $maxloop=8; # the maximum number of words to avoid a too complex search. + $maxloop = @$value if @$value<$maxloop; + + for(my $i=0; $i<=$maxloop;$i++) { if (@$value[$i]) { $nb_active++; if ($nb_active==1) { -- 2.39.5