Should the inner join query be done directly from the database or should it be queried in two stages?

here"s the problem. For a detailed description, please see below.

  1. how should inner join be used compared with separate queries? should inner join be used or should it be considered on a case-by-case basis?
  2. when I have the above doubts, is there any way to experiment on my own to get the results?

the requirement goes something like this: the time to find several qualified user_id, from one table (User) and then go to another table (Post) to find the posts posted by these people.

the first way is clear, inner join:

SELECT create_time
FROM Post
WHERE user_id IN (xxx)
Oct.16,2021

must give priority to using INNER JOIN. If you find out that the user ids array is very large, it will generate a very long string, and it will take extra time to generate a long SQL, database parse this SQL, and if JOIN, the data will have a lot of algorithms to optimize your query, IN can not.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be71a9-45de0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be71a9-45de0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?