After migrating to railway's new database, we are having an issue

Hello, we migrated to the new MYSQL database from the old MYSQL database. I was told we had until the end of the month to do so. Everything seemed to work, but one of our Queries went from taking .08 seconds to taking 43 seconds. Can you please help me understand what could cause this?
select
b.id as boutId,
b.event_id,
b.created_at,
b.match_is_rated,
b.period_1_length_in_minutes,
b.period_2_length_in_minutes,
b.period_3_length_in_minutes,
r1.id as topLineRegistrationId,
w1.id as topLineWrestlerId,
w1.first_name as topLineWrestlerFirstName,
w1.last_name as topLineWrestlerLastName,
w1.birthday as topLineBirthday,
t1.id as topLineTeamId,
t1.team_name as topLineTeamName,
wi1.weight_in_pounds as topLineWeight,
r2.id as bottomLineRegistrationId,
w2.id as bottomLineWrestlerId,
w2.first_name as bottomLineWrestlerFirstName,
w2.last_name as bottomLineWrestlerLastName,
w2.birthday as bottomLineBirthday,
t2.id as bottomLineTeamId,
t2.team_name as bottomLineTeamName,
wi2.weight_in_pounds as bottomLineWeight,
ws.id as wrestlingStylesId,
ws.name_of_style
from bouts b
join registrations r1 on b.top_line_wrestler_registration_id=r1.id
join registrations r2 on b.bottom_line_wrestler_registration_id=r2.id
join wrestlers w1 on w1.id=r1.wrestler_id
join wrestlers w2 on w2.id=r2.wrestler_id
left join teams t1 on t1.id=r1.team_id
left join teams t2 on t2.id=r2.team_id
join weigh_ins wi1 on w1.id=wi1.wrestler_id and wi1.event_id=b.event_id
join weigh_ins wi2 on w2.id=wi2.wrestler_id and wi2.event_id=b.event_id
join wrestling_styles ws on ws.id=b.wrestling_styles_id
where b.dispatch_time_in_utc is null
and b.event_id=?
-- and b.dual_meets_id is null
order by b.created_at asc;
select
b.id as boutId,
b.event_id,
b.created_at,
b.match_is_rated,
b.period_1_length_in_minutes,
b.period_2_length_in_minutes,
b.period_3_length_in_minutes,
r1.id as topLineRegistrationId,
w1.id as topLineWrestlerId,
w1.first_name as topLineWrestlerFirstName,
w1.last_name as topLineWrestlerLastName,
w1.birthday as topLineBirthday,
t1.id as topLineTeamId,
t1.team_name as topLineTeamName,
wi1.weight_in_pounds as topLineWeight,
r2.id as bottomLineRegistrationId,
w2.id as bottomLineWrestlerId,
w2.first_name as bottomLineWrestlerFirstName,
w2.last_name as bottomLineWrestlerLastName,
w2.birthday as bottomLineBirthday,
t2.id as bottomLineTeamId,
t2.team_name as bottomLineTeamName,
wi2.weight_in_pounds as bottomLineWeight,
ws.id as wrestlingStylesId,
ws.name_of_style
from bouts b
join registrations r1 on b.top_line_wrestler_registration_id=r1.id
join registrations r2 on b.bottom_line_wrestler_registration_id=r2.id
join wrestlers w1 on w1.id=r1.wrestler_id
join wrestlers w2 on w2.id=r2.wrestler_id
left join teams t1 on t1.id=r1.team_id
left join teams t2 on t2.id=r2.team_id
join weigh_ins wi1 on w1.id=wi1.wrestler_id and wi1.event_id=b.event_id
join weigh_ins wi2 on w2.id=wi2.wrestler_id and wi2.event_id=b.event_id
join wrestling_styles ws on ws.id=b.wrestling_styles_id
where b.dispatch_time_in_utc is null
and b.event_id=?
-- and b.dual_meets_id is null
order by b.created_at asc;
27 Replies
Percy
Percy11mo ago
Project ID: e714d78b-eec7-4c60-b35e-746bd164eccb
Brody
Brody11mo ago
are you connecting to it via the private network?
Jason Layton
Jason LaytonOP11mo ago
e714d78b-eec7-4c60-b35e-746bd164eccb/service/84d87493-d5fd-405b-bb9e-03cf3e331390?id=23772f52-afe2-4771-8eef-617b24d6793e I don't know what that means. We are connected, and the majority of our queries are working without issue.
Brody
Brody11mo ago
please gives this docs section a read and get back to me https://docs.railway.app/guides/mysql#connect
Jason Layton
Jason LaytonOP11mo ago
We are not connecting privately Why would the new database be so slow with this query compared to the old one?
Brody
Brody11mo ago
could it be in the wrong region?
Jason Layton
Jason LaytonOP11mo ago
I guess that's possible. We have not changed anything. How would I know? The other queries are working quickly though
Brody
Brody11mo ago
you can check the region from within the database's settings
Jason Layton
Jason LaytonOP11mo ago
It's in Oregon, I believe the previous DB was as well, and I believe our server is too. That still doesn't make sense, because the database retrieval is what is taking so long. So far, this is the only one of our queries that we've discovered an issue with.
Brody
Brody11mo ago
the new database is postgres 15, the old database was postgres 13, would the newer version cause issues with your app?
Jason Layton
Jason LaytonOP11mo ago
We are using MYSQL
Brody
Brody11mo ago
my bad, the legacy mysql database and v2 mysql database both use the same version as far as i can tell can you try connecting to it over the private network?
Jason Layton
Jason LaytonOP11mo ago
I wouldn't know how to connect mysql workbench to it over the private network.
Brody
Brody11mo ago
sorry im asking you to configure your app on railway to connect to the database over the private network
Jason Layton
Jason LaytonOP11mo ago
Also, I am connecting to it. If I comment out some of the lines, it runs more efficiently. Is it possible that some of the indexing was lost? I don't understand why the execution would take a longer time. I understand. I tried, and had a hard time connecting it that way. Since it is connecting, and it is working over the public, and the only issue is the length it is taking queries to return, I don't see how the connection could be the issue.
Brody
Brody11mo ago
can you regenerate the indexing?
Jason Layton
Jason LaytonOP11mo ago
How would I do that?
Brody
Brody11mo ago
im sorry but i wouldnt know, as that would be something to do with your app / project
Jason Layton
Jason LaytonOP11mo ago
Yes, but this clearly is a result of migrating... Do we have to migrate? Can I continue to use the database that is working?
Brody
Brody11mo ago
you do need to migrate, legacy databases are going to be shut down on jan 31st
Jason Layton
Jason LaytonOP11mo ago
The migration is breaking my database. Do you have suggestions for how I should handle this?
Brody
Brody11mo ago
was the migration successful?
Jason Layton
Jason LaytonOP11mo ago
I do not believe so. It seems like some data was lost, as the row count is not the same for certain tables. Also, there is the whole issue of this thread.
Brody
Brody11mo ago
you might want to do a manual migration with mysql workbench
Jason Layton
Jason LaytonOP11mo ago
ok, I will try that next. Hopefully that will fix the issue, thank you. To be sure I understand, I'm going to data import with a dump file?
Brody
Brody11mo ago
with the use of mysql workbench, export the data from the legacy database, then import it into the new database
Jason Layton
Jason LaytonOP11mo ago
Cool, thanks I think we have things stable again. This was very stressful and our team had to work late into the night to revert to the database before the migration, while keeping all of the data that changed after the migration. It seems a data dump and data import was a more reliable way to handle the migration than using the tool provided by railway. If other customers are having this issue, you should give them a heads up. Thank you for your help.
Want results from more Discord servers?
Add your server