sql - mysql query with select - where - in - join -


What's the better way to regain multiple lines?

Select in advance * order_details where in order_id (1,2,3, ... ....)

... or:

  Select * Order_details Join INNER from Order Orders.id = order_details.order_id Add customers to INNER customers. ID = Commands customer_id where customers.id = 3  

The first version chooses from a table So, it's less work to do.

However, if another query produces the correct answer, then you have to work with it to create the first two statements to establish the list of order_ID values ​​in the other two tables, in this case the total Workload is high and you will be better off using the second statement completely.

In general, optimizing the SQL Optimizer; This is better for your optimization, and instead of problem pieces, it works best when solving the whole problem.

(The second option will usually perform a total workload for the first, if only DBMS does not have to send the intermediate results back to the client and purse and optimize two different statements.)

In addition, the second statement has a bigger size for the result set (because '*' covers the column from 3 table instead of 1). This is not a fair comparison of two similar SQL statements.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -