- Which of the following 3 Queries will be faster? Why?
- I use such queries with a lot of other joins a lot within my app. so is there any way I can benchmark their speed? If yes, can you please mention what it is/they are?
Query 1:
$q = "SELECT COUNT(books.id) FROM books
INNER JOIN books_type ON books.id = books_type.id
WHERE books_type.book_type = 'Comedy'";
Query 2:
$q = "SELECT COUNT(*) FROM books
INNER JOIN books_type ON books.id = books_type.id
WHERE books_type.book_type = 'Comedy'";
Query 3:
$q = "SELECT books.id FROM books
INNER JOIN books_type ON books.id = books_type.id
WHERE books_type.book_type = 'Comedy'";
$books_count = mysql_num_rows($q);
Thank you.