SQL 2019
3 TopicsSQL queries have become extremely slow compared to nearly identical queries on the same tables
Hi all. I've been drafting a SQL query from within MS SSMS, as a .SQL file, and then running it from within SSMS, on the same system that is running the 2019 developer edition server. The query file contains around 100 or so queries, virtually all UPDATE queries, which populate rows in a SUMMARYTABLE with results taken from the WORKTABLE. I've noticed that recently, the last 10% or so of these queries have become exceptionally slow - around 500 times slower than comparable queries. Here is an example of one of the fast ones, and one of the slow ones. The first takes less than a second: UPDATE database1.dbo.SUMMARYTABLE SET database1.dbo.SUMMARYTABLE.SalesTierCount = (select count(*) from database1.dbo.WORKTABLE as T1 WHERE T1.Manager = database1.dbo.SUMMARYTABLE.Manager and T1.SalesTier =1 and T1.Zdate < database1.dbo.SUMMARYTABLE.Zdate) the second one takes about seven minutes: UPDATE database1.dbo.SUMMARYTABLE SET database1.dbo.SUMMARYTABLE.LifetimeCount = (select count(*) from database1.dbo.WORKTABLE as T1 WHERE T1.retailer = database1.dbo.SUMMARYTABLE.retailer and T1.SalesTier =1 and T1.Zdate < database1.dbo.SUMMARYTABLE.Zdate) Does anyone have any suggestions for rectifying this extremely slow issue? 2 of the 3 WHERE/AND clauses are identical. The third clause differs, however both queries query the same type of data for that clause - both are varchar(50), in both tables. This is a link to the execution plan for both queries: Execution plan The final part of both plans shows an INDEX SCAN (non-clustered). The first, fast query, has the "Number of rows read" of around 200,000, the second, around 436 million. The total time to run the entire .SQL query has blown out from a minute or so, to nearly 4 hours! Any suggestions greatly appreciated.1.3KViews0likes2CommentsGetting Illegal character from SQL DB
We are getting Illegal character (?) while retrieving a nvarchar field(TEMP-WRK-INFO) from a table in a cobol module. Below are region details:- Linux version - RHEL 8.3 MSSQL version - 2019 Initially, we got illegal character while converting the hex value to ASCII value. For example, when the amount of 894.55 is moved to TEMP-WRK-INFO, then hex value of (89 45 5C) is converted to ASCII as (?E\). This issue occurred as extended ASCII value is not converted correctly. We had a fix for this issue by changing the LANG to en_US.CP1252 in environment settings, then it worked for all extended ASCII value except for 81 and 90. When the hex value has the combination of 81 or 90, then we get the illegal characters. Same logic is working fine in windows environment.995Views0likes0Comments