diff --git a/ecrire/inc/prepare_recherche.php b/ecrire/inc/prepare_recherche.php
index 913fc1e4fb683b2d041a93a0684cc876fef7b3a9..3f3111375baa00b4f70e060d404a3b7539463f15 100644
--- a/ecrire/inc/prepare_recherche.php
+++ b/ecrire/inc/prepare_recherche.php
@@ -79,6 +79,10 @@ function inc_prepare_recherche_dist($recherche, $table='articles', $cond=false,
 			$values = "";
 			foreach ($points as $id => $p){
 				$values.= ",(0x$hash,".intval($id).",".intval($p['score']).")";
+				if (strlen($values)>16000) { // eviter les debordements de pile sur tres gros resultats
+					sql_insert('spip_recherches',"(recherche,id,points)",substr($values,1),array(),$serveur);
+					$values = "";
+				}
 			}
 			sql_insert('spip_recherches',"(recherche,id,points)",substr($values,1),array(),$serveur);
 		}