Large scripts still slow
PDinCA
Posts: 642 Silver 1
3.5 Production version is still slow handling longish SPs. The one I wanted to change just three consecutive lines within is only 700 lines in total, with 600 between the AS and GO. The cursor takes 5 to 10 seconds to register at the clicked location, then each cursor movement takes another 5 seconds to register. I made my changes, went to another window, and to Outlook, then came back to add SET NOCOUNT ON at the top of the code, and that took ages, too.
Ideas?
Ideas?
Jesus Christ: Lunatic, liar or Lord?
Decide wisely...
Decide wisely...
Comments
This sounds like a configuration issue. Open the Options dialog by clicking on SQL Prompt > Options from the main menu bar in your editor. Now switch to the "Listed Candidates" tab and select the "Variables and Parameters" screen (bottom link on left-hand side).
If you could tell me how you've got this set up that might give me a clue as to what the problem is, however in general if you're experiencing performance problems I'd recommend selecting "Search a fixed number of lines from the caret (faster)" rather than "Search entire batch/GO block (slower, but more accurate)". There's also a "Tips" section in the web help (available via SQL Prompt > Help on the main menu again) that briefly deals with performance issues.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
Your advice is well taken, but in the cases presented to me, I would have to go through scores of SPs to resituate DECLAREs closest to the first point of use, then run the risk of later changes needing to use the variable before it is declared, just to accommodate SQL Prompt's sluggishness in handling larger blocks of code. My hope is that the SQL Prompt gurus will be able to further optimize the code, and/or find sets of conditions whereby entire blocks don't need to be scanned so frequently, especially when all one is doing is placing the cursor at a character location, then holding Shift while I move the cursor down and over to select three lines then Delete...
Decide wisely...
Principal Consultant
bartread.com Ltd
It doesn't quite explain why just positioning and highlighting a few lines takes 20 seconds or more to complete... I guess that's one for boys...
Decide wisely...
Thanks,
Bart
Principal Consultant
bartread.com Ltd
Yes, the indent a large block is a coffee-break activity... If I remember, I turn Prompt off then indent, then back on. If not, it's time for a wet...
Thanks for the comprehensive answers and clarifications. Maybe I'll take a turn around the help with so many changes being made for 3.5.
Decide wisely...
Cheers,
Bart
Principal Consultant
bartread.com Ltd
INSERT INTO [table_name] (column list) values(1,1,...)
It contains 11 Insert statements into a table with 65 columns.
This is enough to make me turn it off.
Dave J
Are you sure that's not just because it's caching your database for the first time, which if it's large is likely to take some time. Is the toast popup visible in the bottom right hand corner (assuming you didn't close it)? And if you leave it for a few minutes does the CPU usage drop back to normal? I'd also recommend turning off automatic cach updates (uncheck the box in the Cache Management dialog available via SQL Prompt > Cache Management).
Thanks,
Bart
Principal Consultant
bartread.com Ltd
I'm afraid it's definitely not caching. I can open a connection to the db, watch the window appear , then disappear, then load the script and then watch my CPU spike up to 99% for up to 3 minutes. When I get control back, if I click anywhere else in the window, it appears to re-parse and takes an age to come back again. Note, this is just clicking elsewhere in the window, not typing anything.
I can post the table DDL and the DML script if you think it will help you solve this
Dave J
Thanks for getting back to me. Can you open the Options dialog, and then to the "Variable and Parameters" screen on the "Listed Candidates" tab, and then make sure that "Search a fixed number of lines..." is selected please? You might want to try playing with the settings on this page for best results. If that doesn't sort the problem out please let me know.
BTW: there's also some extra info on performance in the Tips and Troubleshooting sections in the online help.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
I did, and it is selected and is set to 50 lines. The script in question contains no parameters or variables btw, it's a straight insert into an admittedly very wide table.
HTH
Dave
Thanks,
Bart
Principal Consultant
bartread.com Ltd
Here you go. Currently, DA_Avery_Txn_Temp contains 2,501,247 rows.
Note, this script creates the table on a file group called SECONDARY.
*/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DA_Avery_Txn_Temp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [DA_Avery_Txn_Temp] (
[Avery_Txn_Id] [int] IDENTITY (1, 1) NOT NULL ,
[Registration] [varchar] (15) COLLATE Latin1_General_CI_AI NULL ,
[Station_No] [varchar] (20) COLLATE Latin1_General_CI_AI NULL ,
[Txn_Dt] [datetime] NULL ,
[Txn_No] [int] NULL ,
[Ticket_No] [int] NULL ,
[Weighing_Mode] [int] NULL ,
[Weighing_Type] [char] (2) COLLATE Latin1_General_CI_AI NULL ,
[Charge_Type] [char] (1) COLLATE Latin1_General_CI_AI NULL ,
[Customer] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Haulier] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Waste] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Destination] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Driver] [varchar] (15) COLLATE Latin1_General_CI_AI NULL ,
[UDF1] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF2] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF3] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF4] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF5] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF6] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF7] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[UDF8] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[First_Weight] [decimal](9, 3) NULL ,
[First_Weight_Unit] [char] (1) COLLATE Latin1_General_CI_AI NULL ,
[First_Weight_Dt] [datetime] NULL ,
[First_Weight_Consec] [decimal](9, 3) NULL ,
[Second_Weight] [decimal](9, 3) NULL ,
[Second_Weight_Unit] [char] (1) COLLATE Latin1_General_CI_AI NULL ,
[Second_Weight_Dt] [datetime] NULL ,
[Second_Weight_Consec] [decimal](9, 3) NULL ,
[Net_Weight] [decimal](11, 3) NULL ,
[Adjusted_Net_Weight] [decimal](11, 3) NULL ,
[Charge_Rate] [money] NULL ,
[Goods_Charge] [money] NULL ,
[VAT] [money] NULL ,
[Price] [money] NULL ,
[Manual_Customer] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Manual_Haulier] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Name1] [varchar] (15) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Name2] [varchar] (15) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Name3] [varchar] (15) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Comments1] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Comments2] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Comments3] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Ded_Reason_Rate1] [money] NULL ,
[Ded_Reason_Rate2] [money] NULL ,
[Ded_Reason_Rate3] [money] NULL ,
[Ded_Reason_Type1] [decimal](9, 3) NULL ,
[Ded_Reason_Type2] [decimal](9, 3) NULL ,
[Ded_Reason_Type3] [decimal](9, 3) NULL ,
[Ded_Total_Units] [decimal](9, 3) NULL ,
[Ded_Total_Weight] [decimal](9, 3) NULL ,
[Source] [varchar] (50) COLLATE Latin1_General_CI_AI NULL ,
[Transfer_Status] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL CONSTRAINT [DV_DA_Avery_Txn_Temp_Transfer_Status] DEFAULT ('N'),
[Error_Desc] [varchar] (255) COLLATE Latin1_General_CI_AI NULL ,
[Created_By] [varchar] (12) COLLATE Latin1_General_CI_AI NOT NULL ,
[Created_Dt] [datetime] NOT NULL ,
[Modified_By] [varchar] (12) COLLATE Latin1_General_CI_AI NOT NULL ,
[Modified_Dt] [datetime] NOT NULL ,
[Ded_Reason_Count1] [decimal](9, 3) NULL ,
[Ded_Reason_Count2] [decimal](9, 3) NULL ,
[Ded_Reason_Count3] [decimal](9, 3) NULL ,
[Ded_Reason_Total1] [money] NULL ,
[Ded_Reason_Total2] [money] NULL ,
[Ded_Reason_Total3] [money] NULL ,
CONSTRAINT [XPKDA_Avery_Txn_Temp] PRIMARY KEY CLUSTERED
(
[Avery_Txn_Id]
) WITH FILLFACTOR = 90 ON [SECONDARY] ,
CONSTRAINT [DA_Avery_Txn_Temp_Transfer_Status] CHECK ([Transfer_Status] = 'N' or ([Transfer_Status] = 'T' or [Transfer_Status] = 'E' or [Transfer_Status] = 'D' or [Transfer_Status] = 'X'))
) ON [SECONDARY]
END
GO
SET NOCOUNT ON
PRINT 'Inserting values into [DA_Avery_Txn_Temp]'
SET NOCOUNT ON
PRINT 'Inserting values into [DA_Avery_Txn_Temp]'
INSERT INTO [DA_Avery_Txn_Temp]
([Registration],
[Station_No],
[Txn_Dt],
[Txn_No],
[Ticket_No],
[Weighing_Mode],
[Weighing_Type],
[Charge_Type],
[Customer],
[Haulier],
[Waste],
[Destination],
[Driver],
[UDF1],
[UDF2],
[UDF3],
[UDF4],
[UDF5],
[UDF6],
[UDF7],
[UDF8],
[First_Weight],
[First_Weight_Unit],
[First_Weight_Dt],
[First_Weight_Consec],
[Second_Weight],
[Second_Weight_Unit],
[Second_Weight_Dt],
[Second_Weight_Consec],
[Net_Weight],
[Adjusted_Net_Weight],
[Charge_Rate],
[Goods_Charge],
[VAT],
[Price],
[Manual_Customer],
[Manual_Haulier],
[Ded_Reason_Name1],
[Ded_Reason_Name2],
[Ded_Reason_Name3],
[Ded_Reason_Comments1],
[Ded_Reason_Comments2],
[Ded_Reason_Comments3],
[Ded_Reason_Rate1],
[Ded_Reason_Rate2],
[Ded_Reason_Rate3],
[Ded_Reason_Type1],
[Ded_Reason_Type2],
[Ded_Reason_Type3],
[Ded_Total_Units],
[Ded_Total_Weight],
[Source],
[Transfer_Status],
[Error_Desc],
[Created_By],
[Created_Dt],
[Modified_By],
[Modified_Dt],
[Ded_Reason_Count1],
[Ded_Reason_Count2],
[Ded_Reason_Count3],
[Ded_Reason_Total1],
[Ded_Reason_Total2],
[Ded_Reason_Total3])
VALUES ('A111AAA',
'LIVAAAA',
'Aug 11 2007 1:54:21:000PM',
400431,
287406,
0,
'2',
'2',
'LLIV004',
'1',
'FF',
'FF',
'ACCOUNT',
'0',
'',
'',
'',
'',
NULL,
'',
'',
6.680,
'1',
'Aug 11 2007 1:38:55:000PM',
128721.000,
4.720,
'1',
'Aug 11 2007 1:54:20:000PM',
128723.000,
1960.000,
1960.000,
NULL,
0.0000,
0.0000,
0.0000,
'LIVERPOOL SALVAGE',
'OWN HAULIER',
'',
'',
'',
'',
'',
'',
0.0000,
0.0000,
0.0000,
1.000,
0.000,
0.000,
0.000,
0.000,
'FEED',
'N',
NULL,
'BORSHA',
'Aug 11 2007 8:28:34:810PM',
'BORSHA',
'Aug 11 2007 8:28:34:810PM',
0.000,
0.000,
0.000,
0.0000,
0.0000,
0.0000)
Firstly, you've fallen victim to a particularly bone-headed piece of regular expression based code that appeared in SQL Prompt 3.5. It didn't cause a problem in previous versions, but as we increased the number of SQL statements supported it became more of a problem, and particularly when coupled with the limited block size parsing, which generally increases performance.
You should find that increasing the block size from 50 lines to 150 lines fixes the problem (it will then be able to parse your complete INSERT statement, whereas at the moment it'll always fail since the statement is 130 lines long due to the size of the table).
Now whilst this will almost certainly improve the situation it probably won't completely cure it. The next version of SQL Prompt, which should be released at some point during September, should fix that.
Hope that helps.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
First of all, you asummed incorrectly, But hey, how could you know? I didn't tell you. The insert script is one line per insert, I formatted so it would look OK in the thread. I increased the number of lines as suggested anyway but no difference. The SECONDAY file group may be a factor, let me try it in a different DB, but put the table in the PRIMARY file group...
Hmm. Seemed to help with the query as posted, but when I loaded the 11 line (1 line to each insert) script, I see the same behaviour.
I do appreciate your efforts in responding to this btw, and your honesty
Dave
I'll create a database using your table definition and then try to recreate the issue with an INSERT script based on the statement you sent.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
http://www.red-gate.com/MessageBoard/vi ... php?t=5457
If disabling the cross-database support improves the performance then it's likely the same issue, if not then I'll need to think again (again).
Thanks,
Bart
Principal Consultant
bartread.com Ltd
http://www.red-gate.com/MessageBoard/vi ... php?t=5606
It's an early access release of SQL Prompt 3.6. I'm hopeful you should see a significant improvement. If not please let me know.
Thanks,
Bart
Principal Consultant
bartread.com Ltd