今天浏览stackoverflow 发现一个有趣的问题: which was more preferable as performance wise and without error cause to delete all the row from table in sqlite in android. DELETE QUERY OR DROP TABLE AND RE-GENERATE THE TABLE? 及关于删除sqlite
今天浏览stackoverflow 发现一个有趣的问题:
which was more preferable as performance wise and without error cause to delete all the row from table in sqlite in android.
DELETE QUERY OR DROP TABLE AND RE-GENERATE THE TABLE?
及关于删除sqlite里面所有数据,用drop并重建比delete all sqlite里面的数据更加有效率
<code><span>it <span>is<span> more efficient <span>to<span> <span>drop<span> <span>table<span> <span>and<span> re-create it<span>;<span> <span>and<span> yes<span>,<span> You can <span>use<span> <span>"IF EXISTS"<span> <span>in<span> this <span>case<span> <span>DELETE<span> <span>FROM<span> will cause SQLite <span>to<span> visit individual <span>rows<span> unless those <span>rows<span> have triggers<span>,<span> so it<span>'<span>s generally reasonably efficient<span>.<span> edited after <span>1<span> answer post <span>As<span> the Droping the <span>table<span> <span>using<span> <span>drop<span> <span>table<span> query <span>then<span> internally <span>delete<span> query was used<span>?<span> <span>As<span> <span>in<span> one answer post</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code><br /><br /><br />"When the WHERE is omitted from a DELETE statement and the table being deleted has no triggers, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individually. This "truncate" optimization makes the delete run much faster. Prior to SQLite version 3.6.5, the truncate optimization also meant that the sqlite3_changes() and sqlite3_total_changes() interfaces and the count_changes pragma will not actually return the number of deleted rows. That problem has been fixed as of version 3.6.5."<br /><br />当忽略来自DELETE语句,表被删除没有触发,SQLite使用一个优化删除整个表内容无需单独访问表的每一行。 这种“截断”优化使得删除运行更快。 3.6.5 SQLite版本之前,截断优化也意味着sqlite3_changes()和sqlite3_total_changes()接口和count_changes编译指示实际上不会返回删除的行数。 这个问题已经固定的版本3.6.5。”<br /><br />SQLite它说:默认的构建,如果一个DELETE语句没有WHERE子句和运营一个表没有触发,导致删除发生发生优化删除和重新创建表。 删除和重新创建一个表通常远远高于逐行删除表的内容。 这是“截断优化”<br />也就是delete有读取一行删除一行的,drop后创建明显效率高些
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号