sql-server - 使用位域和全文搜索查询非常慢
问题描述
我有一个奇怪的问题,如果我执行以下查询,Sql Server(2008 和 2016)大约需要 35 秒才能完成。
SELECT DISTINCT F.FilterTitle, F.FilterSlug, F.FilterOrderList, F.FilterType
FROM products p
JOIN products_translations pt ON pt.ProductId = p.Id AND pt.Culture = 'it'
JOIN facets F ON F.ProductId = p.Id AND F.Culture = 'it' AND F.FilterType = 2
JOIN products_categories pc ON pc.productId = p.id
JOIN categories C ON pc.CategoryId = C.Id
JOIN categories_slugs cps ON cps.CategoryId = C.ParentCategoryId AND cps.Culture = 'it'
JOIN categories_slugs cs ON cs.CategoryId = C.Id AND cs.Culture = 'it'
WHERE cps.value = 'string1' AND cs.value = 'string2'
AND CONTAINS(pt.DescriptionForSearch, '"value*"', LANGUAGE 1040) --this is a full text
AND p.Visible = 1 AND p.Payments = 0 --both are bit fields
ORDER BY F.FilterType, F.FilterOrderList, F.FilterTitle;
如果我评论该行
and p.Visible = 1 and p.Payments = 0
查询只需要几毫秒。如果我删除线也是一样
and contains(pt.DescriptionForSearch, '"value*"' , language 1040)
并保持其他声明不变。我还为两个位字段创建了两个索引而没有更改。
有人可以解释为什么会这样吗?
更新
在此链接上,我忘记包含两个执行计划。
解决方案
推荐阅读
- cytoscape.js - 屏幕布局上的固定位置?
- java - How do I deserialize a series of application.properties to a Map in Java
- c# - How to convert this Oracle query to Linq?
- java - how can i extract ip from String in java
- java - Calling method after Optional.filter() without passing in object
- asp.net-core - 从配置文件配置 JwtBearerOptions
- ios - iOS auto-renewable subscriptions and restoreCompletedTransactions(): is the transaction removed from the queue after expiration or cancellation?
- java - Java 9 JDBC setup
- c# - Xamarin firebase 消息在应用程序处于关闭状态时运行意图
- javascript - 由于服务器和外壳不匹配,无法将 mongoDB 数据库连接到 Atlas