![]() ![]() One option is to calculate an MD5 hash of the full schema of the database, using the following: schema = db. I’m still investigating, but this could mean that I need to find an alternative way of detecting changes to the schema. I’m currently investigating a confounding bug where a user has reported the error message “attempt to write a readonly database” when this PRAGMA schema_version read operation is executed. SQLite has a neat mechanism for doing this: you can run PRAGMA schema_version and it will return a number that increments every time the schema changes. It needs to know so it can update its own in-memory cache of the schema, in order to (eventually) power fast table search across all known databases. Datasette needs to detect any time a SQLite schema changes-which could happen if a table is added or altered in some way. Now run the whole benchmark a second time, but instead of PRAGMA schema_version time how long it takes to run hashlib.md5(db.execute(“select group_concat(sql) from sqlite_master”).fetchall()).hexdigest() instead Background-why compare these two things?Ī bit of background on this. Then add another 100 tables and time PRAGMA schema_version 100 times again. Time how long it takes to execute PRAGMA schema_version against that database 100 times. In Python create an in-memory SQLite database with 100 tables each with 10 columns. One of those libraries is matplotlib.pyplot, and it knows how to both render and display charts using it. The sandbox does not have network access and only has access to a set of pre-approved libraries. I ran the benchmark using the new ChatGPT “Code Interpreter” alpha, which I recently gained access to, presumably due to being in the alpha for ChatGPT Plugins.Ĭode Interpreter mode provides ChatGPT with a single additional tool: it can now generate Python code and execute it in a restricted sandbox. I rendered the difference between the two as this chart:įrom start to finish, this entire benchmarking exercise took me less than five minutes-because ChatGPT did almost all of the work for me. Today I wanted to understand the performance difference between two Python implementations of a mechanism to detect changes to a SQLite database schema. Running Python micro-benchmarks using the ChatGPT Code Interpreter alpha
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |