我有很大的 SQLite 数据库(45MB)。我使用 INNER JOIN 从不同的表中获取数据。但是,它的工作非常缓慢。也许这取决于我正在测试的手机(三星 Galaxy Ace)。应该怎么做才能使查询非常快?a)为表创建索引 b)创建新表,其中将包括我需要的表 c)您推荐的其他方式
我正在使用表格:entry、r_ele、k_ele、sense、gloss with JOIN。
query = "SELECT" + " e.id AS _id," + " ke.id AS ke_id,"
+ " ke.fk as ke_fk," + " ke.value as ke_value,"
+ " re.id AS ke_id," + " re.fk as re_fk,"
+ " re.value as re_value," + " s.id AS s_id,"
+ " s.fk as s_fk," + " g.id AS g_id," + " g.fk as g_fk,"
+ " g.lang," + " g.value as g_value" + " FROM entry e"
+ " INNER JOIN k_ele ke ON e.id = ke.fk"
+ " INNER JOIN r_ele re ON e.id = re.fk"
+ " INNER JOIN sense s ON e.id = s.fk"
+ " INNER JOIN gloss g ON s.id = g.fk"
+ " WHERE g.lang IS NULL AND g.value like '"
+ lookingFor + "%' GROUP BY g.value LIMIT 5 ";