Announcement

Announcement Module
Collapse
No announcement yet.

2 queries really fast, combined really slow

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2 queries really fast, combined really slow

    I've a table like so:

    `fro` int(11),
    `nid` int(11)


    Primary key is fro, nid.
    I have an index on fro and an index on nid
    Storage engine is innodb; I've 3GB dedicated to innodb_buffer_pool_size.

    These two queries are incredibly fast:

    select nid from user_network where fro=506017534;

    2 rows in set (0.00 sec)

    select * from user_network where nid in (50431654, 67108872);

    14590 rows in set (0.05 sec)

    This query is unjustifiably slow.

    select * from user_network where nid in (select nid from user_network where `fro`=506017534);
    14590 rows in set (8.86 sec)


    What's going on? I'm beginning to think something is wrong with my disk...

  • #2
    Mysql does not support this. ver 5
    So using 2 queries is the right choise.

    Comment


    • #3
      Post the output from using EXPLAIN on your query. e.g "EXPLAIN SELECT ..."
      Without that output nobody knows how the DBMS is performing your query.

      Comment

      Working...
      X