diff -ru aspseek-1.2.10/include/sqldb.h aspseek-1.2.10.patched/include/sqldb.h
--- aspseek-1.2.10/include/sqldb.h	Tue Jun 18 21:20:38 2002
+++ aspseek-1.2.10.patched/include/sqldb.h	Tue Sep 30 20:13:38 2003
@@ -567,6 +567,10 @@
 	{
 		return SetQuery("SELECT url_id,site_id,next_index_time FROM urlword WHERE deleted=0 AND hops=:1 AND next_index_time=:2 %s", param);
 	}
+	virtual CSQLQuery * ReplaceWordSiteI(CSQLParam *param)
+	{
+		return SetQuery("UPDATE wordsite SET sites = :1 WHERE word = :2", param);
+	}
 	virtual CSQLQuery * InsertWordSiteI(CSQLParam *param)
 	{
 		return SetQuery("INSERT INTO wordsite(word, sites) VALUES(:1, :2)", param);
@@ -585,7 +589,7 @@
 	}
 	virtual CSQLQuery * GenerateWordSiteS1()
 	{
-		return SetQuery("SELECT word FROM wordsite");
+		return SetQuery("SELECT word,substring(sites,1,161) FROM wordsite");
 	}
 	virtual CSQLQuery * GenerateWordSiteD(CSQLParam *param)
 	{
diff -ru aspseek-1.2.10/include/sqldbi.h aspseek-1.2.10.patched/include/sqldbi.h
--- aspseek-1.2.10/include/sqldbi.h	Tue May 14 21:47:16 2002
+++ aspseek-1.2.10.patched/include/sqldbi.h	Tue Sep 30 19:57:45 2003
@@ -81,6 +81,7 @@
 	void UpdateWordSite(char* hostname, ULONG site_id);	///< Updates "wordsite" table on "real-time" indexing
 	/// Inserts 1 record into "wordsite" table
 	void InsertWordSite(const char* wrd, ULONG* sites, int size);
+	void ReplaceWordSite(const char* wrd, ULONG* sites, int size);
 	/// Adds URLs, produced by given query to the queue of URLs
 	int AddUrls(CSQLQuery *query, double& time, int& maxtime, CIntSet* set);
 	/// Returns next URL ID to index, when ordering by hops is on
diff -ru aspseek-1.2.10/src/sqldbi.cpp aspseek-1.2.10.patched/src/sqldbi.cpp
--- aspseek-1.2.10/src/sqldbi.cpp	Tue Jun 18 21:20:38 2002
+++ aspseek-1.2.10.patched/src/sqldbi.cpp	Tue Sep 30 20:09:55 2003
@@ -321,6 +321,17 @@
 	sql_real_query(sqlquery);
 }
 
+void CSQLDatabaseI::ReplaceWordSite(const char* word, ULONG* sites, int size)
+{
+// "UPDATE wordsite SET sites = '%s' WHERE word = '%s';
+//      pquery = memcpyq(pquery, (char*)sites, size << 2);
+        CSQLParam p;
+	p.AddParamEsc((char*)sites, size << 2);
+        p.AddParam(word);
+	CSQLQuery *sqlquery = m_sqlquery->ReplaceWordSiteI(&p);
+        sql_real_query(sqlquery);
+}
+
 void CSQLDatabaseI::UpdateWordSite(char* hostname, ULONG site_id)
 {
 	hash_map<CWord, ULONG> hmap;
@@ -515,29 +526,55 @@
 	}
 	if (answ) delete answ;
 	logger.log(CAT_ALL, L_INFO, ".");
-// "SELECT word FROM wordsite");
+// "SELECT word,substring(sites,1,161) FROM wordsite");
 	sqlquery = m_sqlquery->GenerateWordSiteS1();
 	answ = sql_query(sqlquery);
+	int counter = 0;
 	while (answ && answ->FetchRow())
 	{
+                if(counter++ == 10000) {
+		    logger.log(CAT_ALL, L_INFO, ".");
+		    counter = 0;
+		}
 		if (strlen(answ->GetColumn(0)) <= MAX_WORD_LEN)
 		{
 			wit = words.find(answ->GetColumn(0));
-// "DELETE FROM wordsite WHERE word = '%s'", row[0]);
-			CSQLParam p;
-			p.AddParam(answ->GetColumn(0));
-			sqlquery = m_sqlquery->GenerateWordSiteD(&p);
-			sql_query2(sqlquery);
+			
 			if (wit != words.end())
 			{
-				vector<ULONG>& sites = wit->second;
-				InsertWordSite(answ->GetColumn(0), &(*sites.begin()), sites.size());
-				words.erase(wit);
+			    vector<ULONG>& sites = wit->second;
+			    ULONG len = answ->GetLength(1);
+			    if(len == 161L) {
+				ReplaceWordSite(answ->GetColumn(0), &(*sites.begin()), sites.size());
+			    } else {
+				if(sites.size() != (len>>2)) {
+				    ReplaceWordSite(answ->GetColumn(0), &(*sites.begin()), sites.size());
+				} else {
+				    ULONG* pold = (ULONG*)answ->GetColumn(1);
+				    if(memcmp(sites.begin(), pold, len) != 0) {
+					ReplaceWordSite(answ->GetColumn(0), &(*sites.begin()), sites.size());
+				    }
+				}
+			    }
+			    words.erase(wit);
+			} else {
+			    // "DELETE FROM wordsite WHERE word = '%s'", row[0]);
+			    CSQLParam p;
+			    p.AddParam(answ->GetColumn(0));
+			    sqlquery = m_sqlquery->GenerateWordSiteD(&p);
+			    sql_query2(sqlquery);
 			}
 		}
 	}
+	logger.log(CAT_ALL, L_INFO, ".");
+	counter = 0;
 	for (wit = words.begin(); wit != words.end(); wit++)
 	{
+        	if(counter++ == 10000) {
+	    	    logger.log(CAT_ALL, L_INFO, ".");
+	    	    counter = 0;
+		}
 		vector<ULONG>& sites = wit->second;
 		InsertWordSite(wit->first.Word(), &(*sites.begin()), sites.size());
 	}
