Skip to content

Commit c8dbebc

Browse files
authored
Merge pull request #642 from ab320012/master
added with (nolock) hint to information_schema.views
2 parents 02529e7 + ab137b8 commit c8dbebc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def data_source_sql(name = nil, type: nil)
276276
scope = quoted_scope name, type: type
277277
table_name = lowercase_schema_reflection_sql 'TABLE_NAME'
278278
sql = "SELECT #{table_name}"
279-
sql << ' FROM INFORMATION_SCHEMA.TABLES'
279+
sql << ' FROM INFORMATION_SCHEMA.TABLES WITH (NOLOCK)'
280280
sql << ' WHERE TABLE_CATALOG = DB_NAME()'
281281
sql << " AND TABLE_SCHEMA = #{quote(scope[:schema])}"
282282
sql << " AND TABLE_NAME = #{quote(scope[:name])}" if scope[:name]
@@ -511,7 +511,7 @@ def view_information(table_name)
511511
@view_information ||= {}
512512
@view_information[table_name] ||= begin
513513
identifier = SQLServer::Utils.extract_identifiers(table_name)
514-
view_info = select_one "SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = #{quote(identifier.object)}", 'SCHEMA'
514+
view_info = select_one "SELECT * FROM INFORMATION_SCHEMA.VIEWS WITH (NOLOCK) WHERE TABLE_NAME = #{quote(identifier.object)}", 'SCHEMA'
515515
if view_info
516516
view_info = view_info.with_indifferent_access
517517
if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000

0 commit comments

Comments
 (0)