954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Fastest Select Qry

Dear team,

Please explain, which one will be faster in Mysql for the following query?

SELECT * FROM `userstatus` where BINARY Name = 'Raja'

[OR]

SELECT * FROM `userstatus` where Name = 'raja'

Db entry for Name field is 'Raja' there is no key for the field.

I have 1000000 records in my db, i tried with "explain" query but both saying same execution time.

Thank you,

With Regards,
Prem2

prem2
Posting Whiz in Training
225 posts since Feb 2010
Reputation Points: 8
Solved Threads: 4
 
i tried with "explain" query but both saying same execution time.


Then there should be no difference.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

EXPLAIN doesn't tell you anything about execution time but only about query optimization.

Then there should be no difference.


Why not? A binary comparison does not need any conversion before the comparison, while a non-binary string comparison requires some operations for case matching. Therefore a non-binary comparison should need more time - though I never saw a relevant performance gap in a real-life application between binary and non-binary comparisons.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

definitely the first query should be quicker

iw2011
Newbie Poster
3 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: