Monday, October 27, 2014

Re: Slow SQL query

mysql> explain SELECT COUNT(*)
   
-> FROM `order_order`
   
-> WHERE `order_order`.`status` != 4
   
-> AND (`order_order`.`user_id` = 12345 OR `order_order`.`account_number`
   
-> = 123456);
+----+-------------+-------------+------+-------------------------------------------------------------------------------------+------+---------+------+--------+-------------+
| id | select_type | table       | type | possible_keys                                                                       | key  | key_len | ref  | rows   | Extra       |
+----+-------------+-------------+------+-------------------------------------------------------------------------------------+------+---------+------+--------+-------------+
|  1 | SIMPLE      | order_order | ALL  | order_order_fbfc09f1,order_order_979d4f1e,order_order_48fb58bb,order_order_309e75c7 | NULL | NULL    | NULL | 338275 | Using where |
+----+-------------+-------------+------+-------------------------------------------------------------------------------------+------+---------+------+--------+-------------+
1 row in set (0.16 sec)

I can't get it to use the indexes when I have the "status" clause.

Anyway, you might be right about using the mysql list.

Thanks,
Collin


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a2366c17-1f66-4606-9e17-c21912d4a225%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment