Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7744483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:46:43+00:00 2026-06-01T09:46:43+00:00

I have a table, TBL1 , with only GUIDs. I have another table, TBL2

  • 0

I have a table, TBL1, with only GUIDs.

I have another table, TBL2, in which the primary key is GUID and it also has some other columns. I want to update one of the columns in TBL2 table based on whether the GUID is in TBL1.

Which of the following queries is faster and/or more reliable to use for that?

MERGE INTO [db].[dbo].[TBL1] AS target
    USING [db].[dbo].[TBL2] as source
        ON target.GUID = source.GUID
    WHEN MATCHED THEN
        UPDATE SET
            StatusColumn = 0;

or

UPDATE [db].[dbo].[TBL1]
    SET StatusColumn=0
    WHERE GUID IN (SELECT GUID FROM [db].[dbo].[TBL2])

or maybe something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:46:45+00:00Added an answer on June 1, 2026 at 9:46 am

    The answer to this question can only come from the execution plan. From the plan you posted (http://i.imgur.com/6vB2t.png) we can see the following:

    • IN is producing a left semi join. This is a little more efficient. There is also an optimizer weakness which causes the optimizer not to generate a semi join from an explicit join even if it could.
    • Merge is sorting rows. This is because you might get duplicates from your join! If that was impossible merge would be just as fast.
    • I guess the explicit join version is exactly as fast as merge.

    Diagnosing this without a plan is just guessing. Look at the plan and/or measure. The measuring provides the answer, but the plan provides the understanding of the answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table A in Oracle that has a primary key (id). I need
I have (all InnoDB) a parent table tbl1 with primary key some_id and child
I have 2 tables tbl1 and tbl2 tbl1 has userid col1 col2 col3 (multiple
I have table with a unique auto-incremental primary key. Over time, entries may be
I have table named A with column B defined int not null Primary Key
I have a database db1 which contains tables tbl1 , tbl2 , and tbl3
I have a table [Tbl1] containing two fields. ID as int And TextValue as
Say i have a table named tbl1 in mysql :- bookid int name varchar(20)
I have the following table in my database: tbl1 PK ClientID ScheduleDay Time1Start Time1Stop
I have basic tables one and two. Let`s call them tbl1 and tbl2. tbl1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.