209 Star 419 Fork 346

开阖软件 Jeff Wang / openerp-china

 / 详情

odoo website 搜索效率问题

待办的
创建于  
2014-09-30 11:05

website录入大量产品后,之前有个 分类页打开超慢的bug,在正式版中已经修复了,但是类似问题在 搜索的时候还是出现了....
随便搜索个产品,时间都得60来秒,跟踪到统计搜索结果的sql语句,
SELECT count(1) FROM "product_template" WHERE ((("product_template"."active" = true) AND (("product_template"."sale_ok" = true) AND ("product_template"."event_ok" IS NULL or "product_template"."event_ok" = false ))) AND (((("product_template"."id" in (WITH temp_irt_current (id, name) as (
SELECT ct.id, coalesce(it.value,ct."name")
FROM product_template ct
LEFT JOIN ir_translation it ON (it.name = 'product.template,name' and
it.lang = 'en_US' and
it.type = 'model' and
it.res_id = ct.id and
it.value != '')
)
SELECT id FROM temp_irt_current WHERE name ilike '%cat%' order by name
)) OR ("product_template"."id" in (WITH temp_irt_current (id, name) as (
SELECT ct.id, coalesce(it.value,ct."description")
FROM product_template ct
LEFT JOIN ir_translation it ON (it.name = 'product.template,description' and
it.lang = 'en_US' and
it.type = 'model' and
it.res_id = ct.id and
it.value != '')
)
SELECT id FROM temp_irt_current WHERE name ilike '%cat%' order by name
))) OR ("product_template"."id" in (WITH temp_irt_current (id, name) as (
SELECT ct.id, coalesce(it.value,ct."description_sale")
FROM product_template ct
LEFT JOIN ir_translation it ON (it.name = 'product.template,description_sale' and
it.lang = 'en_US' and
it.type = 'model' and
it.res_id = ct.id and
it.value != '')
)
SELECT id FROM temp_irt_current WHERE name ilike '%cat%' order by name
))) OR FALSE))

这个单独运行都需要 30秒左右了,
od使用了 ilike '%xxx%' 这样索引应该也没法工作了....
SQL语句改为 like 'xxx%' 测试结果速度明显提高 6s左右 就能完成...

该拿这个怎么办呢?重写搜索部分代码?

评论 (0)

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
Python
1
https://gitee.com/osbzr/openerp-china.git
git@gitee.com:osbzr/openerp-china.git
osbzr
openerp-china
openerp-china

搜索帮助