On Tue, Aug 10, 2021 at 5:16 PM Paul <[email protected]> wrote:

> SELECT * FROM table1 WITH(NOLOCK)
> LEFT JOIN table2 WITH(NOLOCK) ON table1.ID=table2.ID
>

I don't think Sequel has direct support for this SQL (hint after join
table).  However, you should be able to use the equivalent:

DB[:table1].nolock.left_join(DB[:table2].nolock.as(:table2), :id=>:id)
# SELECT * FROM [TABLE1] WITH (NOLOCK)
# LEFT JOIN (SELECT * FROM [TABLE2] WITH (NOLOCK)) AS [TABLE2] ON
([TABLE2].[ID] = [TABLE1].[ID])

I would hope that MSSQL would optimize the query the same way.

More direct support for a lock hint after join table would require
Sequel::SQL::JoinClause support options.  I guess I could consider that,
but if there is a reasonable alternative that optimizes the same way, I
would probably prefer to stick with that.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSf5W9BXpJxCvbtsApWXNq%3DA7M5JktwVuOZv6R0svHModg%40mail.gmail.com.

Reply via email to