MySQL Forums
Forum List  »  Partitioning

Re: Optimizer chooses full table scan
Posted by: Bill Willits
Date: December 12, 2007 11:40AM

I found a much simplier query modifier to improve the performance.
Just add the "STRAIGHT_JOIN" hint between the table specifications.
Check out the difference.

mysql> SELECT COUNT(DISTINCT a.SubscribeID)
-> FROM Subscribers a,Subscriptions b
-> WHERE a.ClientID=509
-> AND a.IsDeleted = 0
-> AND a.SubscribeID=b.SubscriberID;

+-------------------------------+
| COUNT(DISTINCT a.SubscribeID) |
+-------------------------------+
| 71568 |
+-------------------------------+
1 row in set (22 min 6.51 sec)

mysql> SELECT COUNT(DISTINCT a.SubscribeID)
-> FROM Subscribers a STRAIGHT_JOIN Subscriptions b
-> WHERE a.ClientID=509
-> AND a.IsDeleted = 0
-> AND a.SubscribeID=b.SubscriberID ;
+-------------------------------+
| COUNT(DISTINCT a.SubscribeID) |
+-------------------------------+
| 71568 |
+-------------------------------+
1 row in set (4.73 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
5359
December 11, 2007 01:22PM
Re: Optimizer chooses full table scan
3104
December 12, 2007 11:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.