Experience: Sybase SQL query, when passed parameters containing full-width spaces (\u00a0), query slow

Source: Internet
Author: User
Tags sybase sybase database

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.