If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > using order by (performance)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-07-11, 08:50
bchanan bchanan is offline
Registered User
 
Join Date: Dec 2009
Posts: 27
using order by (performance)

Hello All,

I have 2 queries, same same, but different in order by b.spot (in the end).
My question is regarding explain, why does it not effect performance ?

Thanks
Chanan

explain select count(b.id) amount_of_spot, count(distinct b.ukey) unique_player_count, sum(b.amount * b.currency_rate) sum_amount, b.spot from bet b where b.round_id = '2854170' and b.txn_status & '8' = '8' and b.txn_status & '16' = 0 group by b.spot order by b.spot asc;
+----+-------------+-------+------+-------------------------------+------------------+---------+-------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+-------------------------------+------------------+---------+-------+------+-----------------------------+
| 1 | SIMPLE | b | ref | bet_round_id,ind_roundId_ukey | ind_roundId_ukey | 4 | const | 68 | Using where; Using filesort |
+----+-------------+-------+------+-------------------------------+------------------+---------+-------+------+-----------------------------+
1 row in set (0.00 sec)



mysql> explain select count(b.id) amount_of_spot, count(distinct b.ukey) unique_player_count, sum(b.amount * b.currency_rate) sum_amount, b.spot from bet b where b.round_id = '2854170' and b.txn_status & '8' = '8' and b.txn_status & '16' = 0 group by b.spot;
+----+-------------+-------+------+-------------------------------+------------------+---------+-------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+-------------------------------+------------------+---------+-------+------+-----------------------------+
| 1 | SIMPLE | b | ref | bet_round_id,ind_roundId_ukey | ind_roundId_ukey | 4 | const | 68 | Using where; Using filesort |
+----+-------------+-------+------+-------------------------------+------------------+---------+-------+------+-----------------------------+
1 row in set (0.00 sec)
Reply With Quote
  #2 (permalink)  
Old 09-07-11, 08:54
bchanan bchanan is offline
Registered User
 
Join Date: Dec 2009
Posts: 27
is it possible that group by had made the result sorted, and if using order by and group by same field - there is no performance change ?

-Chanan
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On