Which of the following SQL queries will be faster? Joining two tables or sequential queries?

I have two tables here:

ITEMS
ID| DETAILS| .....| OWNER

USERS:
ID| NAME|....

Where ITEMS.OWNER = USERS.ID

I list items with my owner names. To do this, I could use a join on both tables, or I could select all ITEMS and skip them by creating a sql query to get a tuple of this itmes owner. Here's how:

1 sql with JOIN vs 1x20 queries in one sql table

What would be better if you consider the speed? Thanks

+3
source share
4 answers

. - , () . . - , .

: 100 , - .

, - , , benhmark.

!

+3

, JOIN .

20 :

  • 20
  • 20 items
  • 20 ( ).
+6

Connecting will be much faster as well as more efficient practice.

+2
source

Joining will be much faster than executing another query in the child table for each record in the parent table.

You can also include performance data in SQL to see the results for yourself.

http://wraithnath.blogspot.com/2011/01/getting-performance-data-from-sql.html

N

0
source

Source: https://habr.com/ru/post/1786899/


All Articles