github
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/sqlite-utils/issues/366#issuecomment-1009288898 | https://api.github.com/repos/simonw/sqlite-utils/issues/366 | 1009288898 | IC_kwDOCGYnMM48KIbC | 9599 | 2022-01-10T19:54:04Z | 2022-01-10T19:54:04Z | OWNER | Having browsed the API reference I think the methods that would benefit from an `analyze=True` parameter are: - `db.create_index` - `table.insert_all` - `table.upsert_all` - `table.delete_where` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1096563265 | |
https://github.com/simonw/sqlite-utils/issues/366#issuecomment-1009285627 | https://api.github.com/repos/simonw/sqlite-utils/issues/366 | 1009285627 | IC_kwDOCGYnMM48KHn7 | 9599 | 2022-01-10T19:49:19Z | 2022-01-10T19:51:25Z | OWNER | Documentation for those two new methods: https://sqlite-utils.datasette.io/en/latest/python-api.html#optimizing-index-usage-with-analyze | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1096563265 | |
https://github.com/simonw/sqlite-utils/issues/366#issuecomment-1009286373 | https://api.github.com/repos/simonw/sqlite-utils/issues/366 | 1009286373 | IC_kwDOCGYnMM48KHzl | 9599 | 2022-01-10T19:50:22Z | 2022-01-10T19:50:22Z | OWNER | With respect to #365, I'm now thinking that having the ability to say "... and then run ANALYZE" could be useful for a bunch of Python methods. For example: ```python db["dogs"].insert_all(list_of_dogs, analyze=True) db["dogs"].create_index(["name"], analyze=True) ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1096563265 | |
https://github.com/simonw/sqlite-utils/issues/366#issuecomment-1009273525 | https://api.github.com/repos/simonw/sqlite-utils/issues/366 | 1009273525 | IC_kwDOCGYnMM48KEq1 | 9599 | 2022-01-10T19:32:39Z | 2022-01-10T19:32:39Z | OWNER | I'm going to implement the Python library methods based on the prototype: ```diff commit 650f97a08f29a688c530e5f6c9eedc9269ed7bdc Author: Simon Willison <swillison@gmail.com> Date: Sat Jan 8 13:34:01 2022 -0800 Initial prototype of .analyze(), refs #366 diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index dfc4723..1348b4a 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -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": ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1096563265 |