[英]How can I Optimize the Sql query with unindex date column?
我需要优化此查询,因为 creationDate 不是索引列。 所以这需要时间。 以下是查询:-
SELECT
quoteId as 'ID of the quote',
requestType as 'Quote Type',
type as 'New or Change',
taskName as 'Quote Status',
currency.currencyCode as 'Currency Code',
customer.name as 'Customer Name(Contracting Party)',
quote.contractingParty_customerId as 'Customer IC01(Contracting Party)',
customer.salesCountryValue as 'Customer sales country',
item.fpc_financeProductCodeId as 'fpc',
opt.number as "option",
opt.pricingMonthlyAmount as "Monthly existing Charges(Eur).",
opt.pricingOneOffCharges as "Total One-off Charges(EUR)",
opt.customerLabel as "Customer Label",
item.property as "service infomration"
FROM
pqto01.qto_quote quote inner join
pqto01.qto_product_item item on quote.product_productId = item.productItems_productId inner join
pqto01.qto_option opt on opt.options_productItemId = item.productItemId inner join
pqto01.qto_customer customer on customer.customerId = quote.contractingParty_customerId inner join
pqto01.qto_currency currency on quote.pricingCurrency1_currencyId = currency.currencyId
where quote.creationDate between ('2020-03-01' and '2020-03-10') and
(opt.pricingMonthlyAmount = 0 and opt.pricingOneOffCharges = 0);
如果我在没有creationDate 的情况下运行查询,那么它会花费更少的时间,但在mysql 中使用creationDate 需要超过30 秒。 因此,我可以通过任何方式使其更快,而无需索引 creationDate 列。 我使用的数据库是我的 sql。 谢谢你。
opt
我从这个综合指数中受益:
INDEX(pricingOneOffCharges, pricingMonthlyAmount)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.