A
A
Albert Kazan2019-02-14 11:49:14
MySQL
Albert Kazan, 2019-02-14 11:49:14

Which of these two queries is faster/more performant?

These two queries give me what I need.

SELECT d.id, d.author_id, d.msg, d.added_time, u.name AS author_name 
FROM discussion_messages AS d, people AS u 
WHERE u.id=d.author_id AND d.discussion_id=?

SELECT d.id, d.author_id, d.msg, d.added_time, u.name AS author_name 
FROM discussion_messages d
LEFT JOIN people u ON u.id=d.author_id 
WHERE d.discussion_id=?

How to determine what will work faster? I do not like to deal with JOINs, because I did not fully understand them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2019-02-14
@idShura

The queries are the same, only the syntax is different. And to compare requests, you need to look at the execution plan.
upd. Wrong. In the upper case, inner join, and in the lower case, left join (see comments by AltZ and Boris Korobkov )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question