goose icon indicating copy to clipboard operation
goose copied to clipboard

improve Status performance; add ability to retrieve latest N migrations

Open mfridman opened this issue 4 years ago • 2 comments

Currently the implementation of the status command is to loop over all the migrations and get the db metadata one-by-one. I think we can do better by retrieving all migrations at once, although to future proof we could just paginate which would be a few round trips.

This would enable us to list latest N migrations, which has been requested in #254

Lastly, this will enable us to display migrations based on their applied order, instead of their migration file order. See comment https://github.com/pressly/goose/pull/280#issuecomment-945006038. This is important because in #262 we added out-of-order migrations, so the file order no longer is the source of truth.

mfridman avatar Oct 24 '21 14:10 mfridman

I've been interested in improving goose status speed for a little while, I'll try to put a clean PR together.

ble avatar Oct 17 '25 15:10 ble

nice nice -- I walked over to your comment about sorting and took a stab at implementing it -- looking okay so far:

2025/10/17 12:03:43     Wed Sep 24 15:16:56 2025 -- 20250924143305_compacted_airings_lookback_partial_index.sql
2025/10/17 12:03:43     Tue Oct  7 15:02:52 2025 -- 20251007145230_add_dependency_for_byod_tags_builder.sql
2025/10/17 12:03:43     Tue Oct  7 18:50:45 2025 -- 20251007151506_add_fm_monitor_dependency.sql
2025/10/17 12:03:43     Mon Oct 13 15:17:51 2025 -- 20251013150635_add_dependencies_for_byod_tags_linker.sql
2025/10/17 12:03:43     Fri Oct 17 14:36:16 2025 -- 20240604195705_complete_graph_publication.sql
2025/10/17 12:03:43     Pending                  -- 19751017160148_test_migration_old_timestamp.sql
2025/10/17 12:03:43     Pending                  -- 20251017160138_test_migration_recent_timestamp.sql

last 3 migrations there are out-of-order, one being an old migration applied recently, one being a pending migration with old timestamp, and last a pending migration with a new timestamp.

ble avatar Oct 17 '25 16:10 ble