Solutions that result in slow SQL queries for custom functions

Source: Internet
Author: User

In the process of making a report, there is a report to query the exchange rate of the corresponding currency, and the exchange rate in another table, and the criteria for querying the exchange rate is based on the statistical date of the report (page passed in parameters), to the exchange rate table for the date of the last one months of exchange rates, if there is no previous month's exchange rate , therefore, a function that gets the exchange rate is customized, put in SQL, its incoming parameter is the corresponding currency code and the statistic date, so that this function has no way to establish the function index, which causes the query result is very slow, 1.5 million of the data export takes more than 10 minutes.

Later, because the statistical date is determined, the corresponding exchange rate is determined, so another exchange rate table, the exchange rate is what we want to exchange rate, we query the page when the execution of the stored procedure, we want the currency and the corresponding exchange rate to deposit the table.

We simply query the exchange rate of the corresponding currency in the table in the SQL statement, and no longer need to call the function that gets the exchange rate, so the speed is much faster and the time is shortened by almost half.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Solutions that result in slow SQL queries for custom functions

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.