a-hurst / klibs

A simple Python framework for writing cognitive psychology experiments
7 stars 1 forks source link

Add multi-row support for Database.insert #32

Closed a-hurst closed 1 year ago

a-hurst commented 1 year ago

PR Description

This PR adds adds multi-row insertion support to the KLDatabase.Database.insert method, providing massive speedups when inserting many rows of data at a a time.

Previously, inserting rows one-by-one would commit the changes to the database after every row, which is a slow I/O operation (especially on computers with slower storage). When inserting hundreds of rows at once, it could take over 2 seconds in some cases! With these changes, when providing multiple rows to insert in a list, the database changes are only committed once at the end, increasing performance to ~30ms for the same data that took over 2 seconds during testing.

Merge Checklist