Update join vs Update with sub query

Refresh

November 2018

Views

163 time

3

I have 2 tables :

Table A 

ID int,
Name varchar,
Address varchar


Table B 

ID int,
Name varchar,
Address varchar,
Col1...
...
Col100

I want to update A.Name with B.Name based on both table's ID.

UPDATE A 
    SET A.NAME = B.NAME 
    FROM A JOIN (SELECT ID, Name from B) AS B ON A.ID = B.ID 

UPDATE A 
    SET A.NAME = B.NAME 
    FROM A JOIN B AS B ON A.ID = B.ID 

Because I don't have the permission to set the option for viewing execution plan, I ran 2 queries above many times and see the processed time to guess which one has better performance.

With about 700k records, both queries's result slightly differ.

So my question is, if executed, will both queries have the same execution plan? (I mean will the database engine process them by the same way? )

P/S : I'm using SybaseIQ 16.0.0.429

Update : I'm getting the permission for viewing the execution plan. In case both plan are identical, does is mean both queries will be processed the same (100% sure) ?

1 answers

4

Я получил план выполнения. Оба запроса имеют одинаковый план.

И Sybase автоматически «перефразировать» первый запрос, фактически выполняется запрос в точности совпадает со вторым запросом:

UPDATE A 
    SET A.NAME = B.NAME 
    FROM A,B WHERE A.ID = B.ID 

Вывод: оба запроса одинаковы.