Request for documentation, or user experiences, optimizing build_runnner #2699
Replies: 1 comment 5 replies
-
This sounds like an issue worth fixing. Does
For complex builds, I can recommend checking out the modular build mode as well. Instead of drift generating a single |
Beta Was this translation helpful? Give feedback.
-
Hi community!
I have been utilising drift for several months now, and my client-side database has become quite large (schematically).
My ".g.dart" file, produced by drift_dev, is now 55k lines of dart code!
Runtime, I have no complaints - but the build_runner does take at least 2 minutes to execute any time I change something.
I did used to have everything in a single dart file (except for a drift file for views, and one for some complex queries) - and that took over 5 minutes to run - so I have improved somewhat.
I'd like to describe how I reduced that time here, and would love to hear your own similar experiences - perhaps this could eventually go into a best practice guide.
My drift database has 74 tables, 4 daos, and 2 included drift files for views and custom queries.
The best boost I got, was moving all my tables into separate files. I grouped them into files of similar concern (rather than having 74 small files!) - I'm not sure if having 74 small files would be more performant than what I have (6 files with about 6 tables in each - then some leftover tables in the main database .dart file)
That did cause my project to look a little cluttered, and I went to put all these files into a sub-folder, but hit the issue that ".drift" files cannot "include" from a subpath ("/" token syntax not supported by drift parser) - but that is easily resolved, by creating a single dart file in the same folder as the .drift, which "exports" the darts from the sub-folder - you can then include that single file into your drift.
Love to hear any tricks anyone else has observed!
Beta Was this translation helpful? Give feedback.
All reactions