Thank you Jeremy.  Searching through this group I also found this answer 
you gave to another person with same problem, and it worked:

def DB1.dataset
  super.nolock
end
DB1.extend_datasets do
  def join_clause_sql_append(sql, jc)
    super
    sql << " WITH (NOLOCK)" unless jc.table.is_a?(Sequel::Dataset)
  end
end
DB1.send(:reset_default_dataset)

On Tuesday, August 10, 2021 at 9:00:58 PM UTC-4 Jeremy Evans wrote:

> 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/6126f662-a9db-414b-9649-27d2351261c1n%40googlegroups.com.

Reply via email to