mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
db.analyze() and table.analyze() methods, refs #366
This commit is contained in:
parent
b6dad08a83
commit
541f64ddb0
3 changed files with 83 additions and 0 deletions
|
|
@ -923,6 +923,13 @@ class Database:
|
|||
"Run a SQLite ``VACUUM`` against the database."
|
||||
self.execute("VACUUM;")
|
||||
|
||||
def analyze(self, name=None):
|
||||
"Run ``ANALYZE`` against the entire database or a named table or index."
|
||||
sql = "ANALYZE"
|
||||
if name is not None:
|
||||
sql += " [{}]".format(name)
|
||||
self.execute(sql)
|
||||
|
||||
|
||||
class Queryable:
|
||||
def exists(self) -> bool:
|
||||
|
|
@ -2902,6 +2909,10 @@ class Table(Queryable):
|
|||
)
|
||||
return self
|
||||
|
||||
def analyze(self):
|
||||
"Run ANALYZE against this table"
|
||||
self.db.analyze(self.name)
|
||||
|
||||
def analyze_column(
|
||||
self, column: str, common_limit: int = 10, value_truncate=None, total_rows=None
|
||||
) -> "ColumnDetails":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue