sql server - To lower case in PHP or MS SQL -


Like a weird question, I think that PHP is fast, but maybe someone knows better .

The question is:

A table with approximately 10k rows, varchar (550) field. The field is indexed.

The selection of data is too many or -cases and scans such as for each condition. Running

P> query with the PHP script.

Would the lowercase search be faster for search substrings before running a query in the script?

e.g. Regions ('% substring_100%') like

<(>% Substring_1% ') or less ('% substring_2% ') or ... >

or something like this:

  // $ substr_array has all the substrings $ condition = ""; Foreign Currency ($ substr_array $ as substring) {$ condition. = "Like field '%'. Mb_strtolower ($ substring, "UTF-8"). "% 'Or"; } $ Condition = substr ($ bet, 0, -4); $ Query = "SELECT * to table WHERE $ bet"; $ Result = query ($ query);  

This is an opinion based question, but still there is a question. So here my answer goes:

  SELECT * where less area ('% substring_1%') or like lower field ('% substring_2%') or ... like field '% Substring_100%')  

Depending on the scenario, how well you are DB is structured. If you do not have too many records in your database, then there will be no difference in giving us "outstanding" performance that we have nowadays ...

However: "Another method of case-insensitive matching is to use a different" collation. "The default collations used by SQL Server and MySQL do not differentiate between upper and lower case letters - they are by default case-insensitive Are. " (Remove from )

You should read that article, it's great.

Now under the second part. The most expensive, as a display cost, the foreach () statement in the PHP code will take how much time you take foreach () and for < / Code> and are very good comparisons () can find more information on the loop. It is good to know them, basically, whatever you do here, take some time to prepare the first query, which takes time, and then it is actually going on, which is the cost time.

Finally, the real battle will be: Which is faster? A foreach () or lower () function in SQL

by telling me that I've given you some good content, and your own findings Creating, in my opinion, I think the best way to go about this is to simply leave the query and Foreach () , because the queries are the most expensive and the will slow you down. At least you want to cut something from the picture :)

Uje really hope that it will help you!
Keep on coding!
Ares.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -