我是数据库 sql 的新手。我知道索引使查询更快。但我想学习在不删除或创建对象的情况下使查询变慢的方法。
create index ind1 on students_2(surname);
select * from students s1, students_2 s2
where s1.name1=substr(s2.surname,1,5) and s1.dep=s2.dep and
s1.dep in ('Econ','Law')
最佳答案
您可以将 sleep 嵌入到任何表达式中。
select *
from students s1
join students_2 s2
on s1.name1=substr(s2.surname,1,5) and s1.dep=s2.dep
where s1.dep in ('Econ','Law')
and sleep(0.1)=0;
这将在每次检查一行时增加 0.1 秒的 sleep 时间。 sleep() function通常返回 0。
P.S.:请使用正确的 JOIN
语法,而不是过时的“逗号”连接。
关于mysql - 如何减慢我的查询速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41055040/