Created
August 22, 2016 15:49
-
-
Save tjtate/993a819a26b5b3a0647966a5d2ff275e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using this Table definition... | |
CREATE TABLE test ( | |
id INT NOT NULL, | |
last_name CHAR(30) NOT NULL, | |
first_name CHAR(30) NOT NULL, | |
PRIMARY KEY (id), | |
INDEX name (first_name, last_name) | |
); | |
Which query is faster for selecting a user's first name? | |
SELECT * FROM test WHERE first_name = 'john' AND last_name = 'smith' | |
SELECT first_name FROM test WHERE last_name = 'smith' AND first_name = 'john' | |
Is one query more efficient than the other? | |
SELECT * FROM test WHERE last_name = 'smith' AND first_name = 'john' | |
SELECT * FROM test WHERE first_name = 'john' AND last_name = 'smith' | |
Will this query use the "name" index? | |
SELECT * FROM test WHERE last_name = 'smith' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment