I've tried various combinations e.g. where (len(ltrim(custname))>0 and custname like '%abc%' ) or (len(ltrim(address))>0 and address like '%abc%') Makes no real difference.
________________________________ From: ProFox on behalf of Fred Taylor Sent: Sun 10/02/2013 17:30 To: ProFox Email List Subject: Re: SQL Server optimisation SInce you're building up the SQL statement, are you only including fields they entered a value for in your WHERE clause? Fred On Sun, Feb 10, 2013 at 8:39 AM, Graham Brown <[email protected]> wrote: > 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.

