-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sqlserver连表with(nolock)问题 #398
Comments
生成的 SQL: SELECT COUNT(0)
FROM ACM_User_Schedule AUS WITH (NOLOCK)
LEFT JOIN Client_Register CR WITH (NOLOCK)
ON AUS.BookBy = CR.ClientID
AND CR.SourceType = 'F'
AND AUS.ClientRegisterNum = CR.ClientRegisterNum
INNER JOIN ACM_User AU WITH (NOLOCK) ON AU.UserID = AUS.DoctorID
INNER JOIN Code_Clinic CC WITH (NOLOCK) ON AUS.ClinicID = CC.CodeID
INNER JOIN Clinic_Detail CD WITH (NOLOCK) ON CC.CodeID = CD.ClinicID
INNER JOIN Code_Area A1 WITH (NOLOCK) ON CD.AreaLevel1ID = A1.CodeID
INNER JOIN Code_Area A2 WITH (NOLOCK) ON CD.AreaLevel2ID = A2.CodeID
INNER JOIN Company_Master CM WITH (NOLOCK) ON CC.SystemID = CM.SystemID
WHERE BookBy = 1
------------------
SELECT TOP 10 ScheduleID, SystemID, ClinicID, DoctorID, ScheduleDate
, StartTime, EndTime, Status, BookBy, Note
, Remark, SourceType, CompanyName, DoctorName, DoctorNumber
, ClinicName, Lat, Lng, ContactTel, Address
, ConsultationStatusID, RegisterStatus, AreaLevel1, AreaLevel2
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY RAND()) AS PAGE_ROW_NUMBER, ScheduleID, SystemID, ClinicID, DoctorID
, ScheduleDate, StartTime, EndTime, Status, BookBy
, Note, Remark, SourceType, CompanyName, DoctorName
, DoctorNumber, ClinicName, Lat, Lng, ContactTel
, Address, ConsultationStatusID, RegisterStatus, AreaLevel1, AreaLevel2
FROM (
SELECT AUS.ScheduleID, AUS.SystemID, AUS.ClinicID, AUS.DoctorID, AUS.ScheduleDate
, AUS.StartTime, AUS.EndTime, AUS.Status, AUS.BookBy, AUS.Note
, AUS.Remark, AUS.SourceType, CM.CompanyName, AU.UserName AS DoctorName, AU.UserNumber AS DoctorNumber
, CC.CodeDesc AS ClinicName, CD.Lat, CD.Lng, CD.ContactTel, CD.Address
, CR.ConsultationStatusID, CR.RegisterStatus, A1.CodeDesc AS AreaLevel1, A2.CodeDesc AS AreaLevel2
FROM ACM_User_Schedule AUS WITH (NOLOCK)
LEFT JOIN Client_Register CR WITH (NOLOCK)
ON AUS.BookBy = CR.ClientID
AND CR.SourceType = 'F'
AND AUS.ClientRegisterNum = CR.ClientRegisterNum
INNER JOIN ACM_User AU WITH (NOLOCK) ON AU.UserID = AUS.DoctorID
INNER JOIN Code_Clinic CC WITH (NOLOCK) ON AUS.ClinicID = CC.CodeID
INNER JOIN Clinic_Detail CD WITH (NOLOCK) ON CC.CodeID = CD.ClinicID
INNER JOIN Code_Area A1 WITH (NOLOCK) ON CD.AreaLevel1ID = A1.CodeID
INNER JOIN Code_Area A2 WITH (NOLOCK) ON CD.AreaLevel2ID = A2.CodeID
INNER JOIN Company_Master CM WITH (NOLOCK) ON CC.SystemID = CM.SystemID
WHERE BookBy = 1
) PAGE_TABLE_ALIAS
) PAGE_TABLE_ALIAS
WHERE PAGE_ROW_NUMBER > 1
ORDER BY PAGE_ROW_NUMBER |
找到你失败的原因了。。 默认的 ReplaceSql 支持不了,应该选择 regex 方式,参考: 明天发布 5.1.10 版本,仅仅修改一个默认值。 |
看你生成的sql是使用sqlserver2005的方式row_number方式,我使用的是sqlserver2012方式,fetch...next.. |
@yccool 5.1.10 还有问题吗? |
再等你的5.1.10版本呀,没看到你发布到maven仓库啊,现在还没用上5.1.10版本呢 |
还有就是针对springboot版本的:https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter |
我在springboot里面的pom.xml里面这样应用: 但是还是跟以前一样啊,无法解决链表with(nolock)的问题,你真的在springboot里面测试过吗? |
我在mybatis里面用的sql语句
但是最后生成的sql:
SELECT count(0) FROM ACM_User_Schedule AUS with(nolock) LEFT JOIN Client_Register CR with(nolock) INNER JOIN ACM_User AU with(nolock) INNER JOIN Code_Clinic CC with(nolock) INNER JOIN Clinic_Detail CD with(nolock) INNER JOIN Code_Area A1 with(nolock) INNER JOIN Code_Area A2 with(nolock) INNER JOIN Company_Master CM with(nolock) WHERE BookBy = 213361
没有了on条件,所以还是没有解决链表sqlserver的with(nolock)问题啊
The text was updated successfully, but these errors were encountered: