Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The migration is run in a batch, so I can't take advantage of devels query log. Something like that would be useful in the UI.
Comments
Comment #1
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedThe problem I wanted to debug yesterday got worse, linear (or so) dropping with the number of imported items.
Looks like some slow query is doing this. How can I find it or how can I EXPLAIN sql built using the query builder?
Comment #2
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedUpdate: Fixed the query, speed increased dramatically. Then again, dropping. Now I am importing from a copy of the table, deleting now and then the rows that are already imported, which works fine.
That makes it look to me like a bug. (Now this issue was a feature request, support request and a bug report^^).
Might it have something to do with array('map_joinable' => FALSE)?
Comment #3
mikeryanHave you examined the performance with xhprof, or drush migrate-import --instrument=timer?
Comment #4
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedI didn't try xhprof yet. As for --instrument-timer, I am using migrate_ui, where that doesn't seam to be available. (Nice to have feature, btw?).
I have the full data on the server where only migrate_ui is available and a subset on my local machine for testing. Server fails with migrate_ui, local machine runs great using drush. I'll try to verify the problem with the full data, but I think (speculation as of now) the problem is somehow specific to migrate_ui.
Comment #5
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedComparing migrate_ui and drush on the same dataset on my local machine (notebook with a slow harddisk).
Importing 20k nodes (100k total) in migrate_ui works well, then speed drops and importing with item limit 5 in migrate_ui looks like that:
In drush it looks like that:
I don't know the migrate internals well enough to be sure, but I think the initial work before the actual import looks quite expensive. migrate_ui has to repeat that for every max_execution_time and often no time is left for real importing. Dush can do the initial work once and then run the imports without worries about max_execution_time.
I tried importing from a copy of the source table, deleting rows after they were imported. That helped and increased speed in migrate_ui. I'll go with that for now.
Any other things I could try or could migrate somehow cache the initial work, if that's the point?
Comment #6
mikeryanYep. One reason Drush should be used for migrations whenever possible - max_execution_time means when using the batch API you're paying the overhead over and over and over, using the UI is much less efficient.
So, your problem is in the 31707 calls to mapRowBySource - i.e., as you suggested in comment #2, because map_joinable is FALSE. If the map table can't be joined to the source query, then on each invocation migrate has to look up each source record individually against the map table until it finds 1 (or with --limit="5 items", 5) that can be imported. With a short max_execution_time, it just doesn't catch up to the "next" record in time.
Your options are:
Do any of these work for you?
Comment #7
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedThank you mikeryan.
(1) I should probably change hosting, so that I can ssh in and use drush. Otherwise I'll have to use workarounds for now.
(2) That isn't possible as of now, but I could always copy the table over.
(3) Highwater marks didn't speed up the import.
Should I open a seperate issue for
a query log or* something like --instrument=timer in the UI? Those would have helped debugging this issue.* Edit: Maybe not a query log. That would be a lot of queries^^
Comment #8
mikeryanWe can repurpose this issue for doing timer input in the UI. Seems like we've set a drupal.org record for category changes (among support request/feature request/bug report) for this issue, but that's OK:-).
Comment #9
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedIt was already a feature request, so that's nothing new ;) Thanks again.
Comment #10
pifagor