Not the answer you need?
Register and ask your own question!

Slow query with IN

sixartsixart EntrantCurrent User Role Beginner

I have problem with query with IN option, is very slow or I have DEADLOCK.

The query is:
SELECT * FROM token WHERE id in
(SELECT token_id FROM tokeninfo WHERE `Value` = '546845')
in this case or is very slow or I have "ERROR 1213 - Deadlock found when trying to get lock;"

If my query is "SELECT * FROM token WHERE id in ('367'), it is very fast.

Where is the problem?



  • howkeyhowkey Entrant Inactive User Role Beginner
    The problem will be slow subselect
    SELECT token_id FROM tokeninfo WHERE `Value` = '546845'
    . Look if it is using any index by running EXPLAIN on that query. How many rows do you have in the table tokeninfo?
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.