Sqlite Sql查询性能低下
我正在编写一个SQL查询,它的性能很慢。正因为如此,它给了我504网关超时问题。请帮助我重新生成此查询,以便更快地输出结果。我将把问题放在下面Sqlite Sql查询性能低下,sqlite,Sqlite,我正在编写一个SQL查询,它的性能很慢。正因为如此,它给了我504网关超时问题。请帮助我重新生成此查询,以便更快地输出结果。我将把问题放在下面 select r.c1, parent_item.c2, parent_item.c3, parent_item.c4, parent_item.c5, parent_item.c6, parent_item.c7, pt.c8, child_item.c9, t.c10, child_item.c11, f
select
r.c1,
parent_item.c2,
parent_item.c3,
parent_item.c4,
parent_item.c5,
parent_item.c6,
parent_item.c7,
pt.c8,
child_item.c9,
t.c10,
child_item.c11,
from
table1 child_item,
table2 t,
table3 r,
table1 parent_item,
table4 pt
where
r.col1 = child_item.id and
t.id=child_item.typeid and
parent_item.id = r.parent_itemid and
pt.id = parent_item.typeid and parent_item.id=800 and
parent_item.id = (select
itemid
from
table5
where
itemid=parent_item.id
((10!= 1) ? and (holder_itemid in (10,100) and level > 0): "")) and
child_item.id = (select
itemid
from
table5
where
itemid=child_item.id
((10 != 1) ? and (holder_itemid in (10,100) and level > 0) : ""))
order by
r.parent_itemid,
r.relation_typeid,
r.ordinal
这可能是两个子查询,但我们没有足够的关于您的模式的信息 你应该通过解释运行你的查询,看看它说了什么
联接可能会有所帮助,但同样,我们不能确定。如果我们不知道您的数据库模式,则很难准确指出性能问题。(数据库模式表示表定义、索引等) 还有,这个钻头应该做什么
((10!= 1) ? and (holder_itemid in (10,100) and level > 0): ""))
AFAICS,这不是一个有效的SQL查询,将导致语法错误。我再次简化了此查询,但仍然存在问题,我正在添加简化的查询,您能否更有效地简化它。可能的重复