Full text search (not installed on a SQL Server database by default) is your friend.
Dave -----Original Message----- From: ProFox [mailto:[email protected]] On Behalf Of Graham Brown Sent: 10 February 2013 15:40 To: ProFox Email List Subject: SQL Server optimisation Hi all I'm trying to work out whether it is possible to optimise a query on approx. 70,000 records. The problem is that the customer wants to do an "All fields" search so I have something like: - nH=sqlstringconnect(gcConnString) cSQL="select f_rn from tablename where field1 like '%ABC%' or field2 like '%ABC%' or field3 like '%ABC%' ...." sqlexec(nH,cSQL,"curs") The sql select statement contains about 20 fields. One of these fields is also a text/memo column. I also had the query as select f_rn from tablename where (field1+field2+field3...) like '%ABC%' but that was always over a minute to run I built indices on most of the fields but sometimes it takes 2-3 seconds whereas other times it can take over a minute to run exactly the same query. Doesn't matter if use pass-thru or directly into the query analyser, result is either 2-3 seconds or over a minute. If I limit this search to less than 5 fields the result is always returned quickly 2-3 seconds as far as I can see. Not sure whether the 2-3 seconds on the full query is just SQL caching the results. Does anyone know of any possible solutions to this one please? Also looking at full text search to see if that provides the answer. I'm just thinking I should just tell the customer "fast and all fields" is just not possible. Regards Graham [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[email protected] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

