Today, I ran into a problem with a Sybase database query. A simple SQL, but do not know why the query does not come out, resulting in the production of the production server frequently hang out. Scared my little heart to bang.
Select as Fcilcde from dnd_event_log A WHERE a.doc_ref =? and A.doc_type =? ' S '
Later, the network Operations Manager, the original customer passed the parameter contains a special character, that is, the escape of the full-width space (\u00a0).
The reason is because:
Dnd_event_log This table data volume is particularly large, there are about 400 million records. Indexes may not work when there are special characters, and it can take a lot of time to do a table scan. Therefore, it is necessary to apply the user input to check filtering, to prevent meaningless special characters as SQL parameters passed in.
Workaround:
In fact, this problem is very good solution. Just trim the passed parameters a bit.
params. Docref = $.trim (JQuery ("#docRef"). Val ()); // Parameters
Summary: Through this question, I found, or write their own code is not rigorous, thinking problems are not comprehensive. If you consider removing a space in advance, you will not be able to cause such or more series of questions about whitespace.
After a lot of effort Oh!!
Experience: Sybase SQL query, when passed parameters containing full-width spaces (\u00a0), query slow