如何使用取消索引日期列优化 Sql 查询?
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 的查询,那么它花费的时间更少,但是 creationDate 在 mysql 中花费的时间超过 30 秒。所以,无论如何我都可以在不索引 creationDate 列的情况下使其更快。我使用的数据库是我的 sql。谢谢。
opt
可能受益于这个综合指数:
INDEX(pricingOneOffCharges, pricingMonthlyAmount)
我需要优化此查询,因为 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 的查询,那么它花费的时间更少,但是 creationDate 在 mysql 中花费的时间超过 30 秒。所以,无论如何我都可以在不索引 creationDate 列的情况下使其更快。我使用的数据库是我的 sql。谢谢。
opt
可能受益于这个综合指数:
INDEX(pricingOneOffCharges, pricingMonthlyAmount)