Comment #2 on issue 1328 by [email protected]: ibus-table speed up: query first 6 entry in step 1
http://code.google.com/p/ibus/issues/detail?id=1328

避免延迟的补丁。

1. 删除 tabsqlitedb.py 中 select_words() 里的乱七八糟的东西。既然排序操作在 sql查询的时候已经做了,看不出为什么后面还要自己排序,python 排序时调用 compare 会非常慢。只要删除重复的结果,应该就可以了。

2. table.py 中 map ( self.ap_candidate,self._candidates[0] )这一句,当有 3000多结果时,会有非常慢。改成渐进填入结果,只有在需要更多结果的时候(翻页时 ),才填入下一组结果。

基本上解决了 ibus-table 大词库速度慢的问题。

当然如果还有更巨量的词库,可以考虑在select_words()的sql query 最后加 上 "LIMIT 3000",让每次查询返回结果少于3千。基本上不会有人翻到3000个结果后面 的内容,1000以后的都没那个耐心:

sqlstr = '''SELECT * FROM (SELECT * FROM main.phrases WHERE mlen < %(mk)d %(condition)s
            UNION ALL
            SELECT * FROM user_db.phrases WHERE mlen < %(mk)d %(condition)s
            UNION ALL
            SELECT * FROM mudb.phrases WHERE mlen < %(mk)d %(condition)s )
ORDER BY mlen ASC, user_freq DESC, freq DESC, id ASC LIMIT 3000;''' % { 'mk':_len+x_len, 'condition':_condition}




Attachments:
        ibus-speedup-test.patch  4.5 KB

--
You received this message because you are subscribed to the Google
Groups "ibus-devel" group.
iBus project web page: http://code.google.com/p/ibus/
iBus dev group: http://groups.google.com/group/ibus-devel?hl=en

回复