MySQL Hangs

Gps mana year ago
SELECT tc_positions.* FROM tc_positions WHERE id IN (SELECT positionId FROM tc_devices)

I am using AWS RDS and not sure, what api / function is calling above query, which hangs MYSQL.

The CPU utilization rises to 100% and AAS goes beyond 300

Anton Tananaeva year ago

Maybe AWS is using an ancient version of MySQL that didn't know how to handle this query?

Gps mana year ago

Any suggestions I should look into setting any parameters. I am using mysql 8.0.33

Anton Tananaeva year ago

You need to check the query execution plan to see why it takes so long. It's probably not using indexes for some reason.

Gps mana year ago
Anton Tananaeva year ago

It looks good to me. I don't understand why it would hang on it though. Either this is not the query that it hangs on or there's some serious problem with your database.

Richard Creera year ago

How about

Select tc_positions.* from tc_positions
Join tc_devices on id = positionid
Gps mana year ago

This requires code level change ? As we are not doing this query

Richard Creera year ago

Could you use a mysql utility to run and compare the two?

Also I've seen it suggested that max_allowed_packet may need increasing for large IN clauses.

Gps mana year ago

appreciate your response the result of this is faster compared to the original query

Select tc_positions.* from tc_positions Join tc_devices on tc_positions.id = positionid

i have increased the max_allowed_packet to 32 MB from default 16 MB. But in query execution level it didnt made any change

Gps mana year ago

additionally, if you can please guide which api is using this query, it may help to drill down the cause

Gps mana year ago

Can I do this query change in default.xml ?? Id yes how