From newsgrps at dalyn.co.nz Sun Apr 2 21:02:37 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Mon, 03 Apr 2006 14:02:37 +1200 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views Message-ID: <7.0.1.0.0.20060403134107.01b63460@dalyn.co.nz> Cross posted AccessD SQL SQL2000 I have a stored procedure that is based on a number of views. I have two different databases that have the same tables, views and stored procedures. The only difference is that the data is for separate companies. Both databases are on the same server. I developed one set of queries and stored procedure in one of the databases. The main part of the stored procedure is as follows: SELECT dbo.vwAgedDebtorGet.CustomerID, dbo.vwAgedDebtorGet.StatementID, dbo.vwAgedDebtorGet.AccountNo, dbo.vwAgedDebtorGet.CustName, dbo.vwAgedDebtorGet.StatementDate, dbo.vwAgedDebtorGet.StatementNumber, dbo.vwAgedDebtorGet.AccFreq, dbo.vwAgedDebtorGet.CurrentMth, dbo.vwAgedDebtorGet.OneMonth, dbo.vwAgedDebtorGet.TwoMonths, dbo.vwAgedDebtorGet.ThreeMonths, dbo.vwAgedDebtorGet.NoOverdueNote, dbo.vwAgedDebtorReceipt.NetReceipts, dbo.vwAgedDebtorReceipt.GJCredit, dbo.vwAgedDebtorReceiptInv.NetReceiptsInv, dbo.vwAgedDebtorReceiptInv.GJCreditInv, dbo.vwAgedDebtorGet.MGrpIDNo, dbo.vwAgedDebtorGet.DDRegistered, dbo.vwAgedDebtorGet.DDFrequency, dbo.vwAgedDebtorGet.PayArrange, dbo.vwAgedDebtorReceiptNotPost.ReceiptNotPost AS ReceiptsNotPosted, dbo.vwAgedDebtorGet.VIPCust, dbo.vwAgedDebtorGet.AccStatus FROM dbo.vwAgedDebtorGet INNER JOIN dbo.vwAgedDebtorGetLastStatDate ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorGetLastStatDate.CustIDNo AND dbo.vwAgedDebtorGet.StatementDate = dbo.vwAgedDebtorGetLastStatDate.StatementDate LEFT OUTER JOIN dbo.vwAgedDebtorReceipt ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorReceipt.CustIDNo AND dbo.vwAgedDebtorGet.StatementNumber = dbo.vwAgedDebtorReceipt.StatNum LEFT OUTER JOIN dbo.vwAgedDebtorReceiptInv ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorReceiptInv.CustIDNo AND dbo.vwAgedDebtorGet.StatementNumber = dbo.vwAgedDebtorReceiptInv.InvNum LEFT OUTER JOIN dbo.vwAgedDebtorReceiptNotPost ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorReceiptNotPost.CustIDNo In the SQL database that this was developed in it runs fine (in about 30 seconds). However, when I script the objects and restore them into the second database, the same stored procedure runs for over 10 minutes with about a fifth of the data. Is there some optimizing that I need to do to get the second database to work as fast as the first one? Regards David Emerson Dalyn Software Ltd New Zealand From newsgrps at dalyn.co.nz Sun Apr 2 21:49:11 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Mon, 03 Apr 2006 14:49:11 +1200 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views Message-ID: <7.0.1.0.0.20060403144712.01abbb48@dalyn.co.nz> Cross posted AccessD SQL SQL2000 Another thing I have noticed - When I view task manager, the first programme fluctuates between 80-90% of the CPU usage, but when run on the second database (the one which takes so long to process) the CPU usage sits on 99%. Regards David Emerson Dalyn Software Ltd New Zealand From newsgrps at dalyn.co.nz Sun Apr 2 22:15:49 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Mon, 03 Apr 2006 15:15:49 +1200 Subject: [dba-SQLServer] [AccessD] Optimizing Stored Procedures and Views In-Reply-To: <002401c656c7$984076c0$6501a8c0@PAPPARUFF> References: <7.0.1.0.0.20060403134107.01b63460@dalyn.co.nz> <002401c656c7$984076c0$6501a8c0@PAPPARUFF> Message-ID: <7.0.1.0.0.20060403151517.01b54d00@dalyn.co.nz> Thanks John, I checked all the indexes and they seem to be the same. David At 3/04/2006, John Ruff wrote: >Check your indexes in the tables that make up the views on the db that is >running slow and compare them with the same tables in the db that is running >fast. I'd venture to say you don't have one or more columns indexed in the >slow db that should be indexed. From michael at ddisolutions.com.au Sun Apr 2 22:56:05 2006 From: michael at ddisolutions.com.au (Michael Maddison) Date: Mon, 3 Apr 2006 13:56:05 +1000 Subject: [dba-SQLServer] [AccessD] Optimizing Stored Procedures and Views Message-ID: <59A61174B1F5B54B97FD4ADDE71E7D0116A46A@ddi-01.DDI.local> Where to begin... Try clearing the buffer on the fast db to see if it takes longer if the cache is cleared. dbcc dropcleanbuffers with no_infomsgs dbcc freeproccache with no_infomsgs Make note of any diffs in the 2 Execution plans, take note of any parallelism used by either. Add [ WITH RECOMPILE ] to sproc definition Rebuild stats read http://www.sql-server-performance.com/default.asp cheers Michael M DDI Solutions Pty Ltd michael at ddisolutions.com.au Bus: 0260400620 Mob: 0412620497 www.ddisolutions.com.au -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Monday, 3 April 2006 1:16 PM To: Access Developers discussion and problem solving; dba-SQLServer at databaseadvisors.com Subject: Re: [dba-SQLServer] [AccessD] Optimizing Stored Procedures and Views Thanks John, I checked all the indexes and they seem to be the same. David At 3/04/2006, John Ruff wrote: >Check your indexes in the tables that make up the views on the db that >is running slow and compare them with the same tables in the db that is >running fast. I'd venture to say you don't have one or more columns >indexed in the slow db that should be indexed. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Mon Apr 3 16:34:51 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 3 Apr 2006 14:34:51 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: <7.0.1.0.0.20060403144712.01abbb48@dalyn.co.nz> References: <7.0.1.0.0.20060403144712.01abbb48@dalyn.co.nz> Message-ID: David, I might have missed your first post. I'm curious to know what is your server configuration like?, memory, hdd, raid, and of course... index defrags. On 4/2/06, David Emerson wrote: > Cross posted AccessD SQL > > SQL2000 > > Another thing I have noticed - When I view task manager, the first > programme fluctuates between 80-90% of the CPU usage, but when run on > the second database (the one which takes so long to process) the CPU > usage sits on 99%. > > Regards > > David Emerson > Dalyn Software Ltd > New Zealand > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From darrend at nimble.com.au Tue Apr 4 00:13:05 2006 From: darrend at nimble.com.au (Darren DICK) Date: Tue, 4 Apr 2006 15:13:05 +1000 Subject: [dba-SQLServer] (no subject) Message-ID: <20060404051251.HKCX17345.omta04ps.mx.bigpond.com@DENZILLAP> Hi all Cross Posted to AccessD list I am outputting reports to Excel from reporting services (SQL) The reports have many tables on them with differing column widths When I output the reports to Excel I find many columns with no data in them Is there a way I can write some VBA and have it determine the last row on the sheet with a value in it determine if there is any data in any cell from the top to the bottom - if there is no data in the column delete it. Then 'tighten' all the columns? E.G. Column A has data, column B not data, column c has data Delete column b and move column C to the left E.G. AirCode For my sheet find last.row with data ' that becomes the base point find last.column with data ' that becomes a base point loop through columns & rows for A to last column from 1 to last row if data = null then delete column currentcolumn blah blah blah Many thanks in advance Darren From fhtapia at gmail.com Tue Apr 4 08:59:07 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 4 Apr 2006 06:59:07 -0700 Subject: [dba-SQLServer] (no subject) In-Reply-To: <20060404051251.HKCX17345.omta04ps.mx.bigpond.com@DENZILLAP> References: <20060404051251.HKCX17345.omta04ps.mx.bigpond.com@DENZILLAP> Message-ID: why not tighten up the sproc or view that drives the report? eliminate nulls or empty values On 4/3/06, Darren DICK wrote: > Hi all > Cross Posted to AccessD list > I am outputting reports to Excel from reporting services (SQL) > The reports have many tables on them with differing column widths > When I output the reports to Excel I find many columns with no data in them > > Is there a way I can write some VBA and have it determine the last row on the > sheet with a value in it > determine if there is any data in any cell from the top to the bottom - if there > is no data in the column > delete it. Then 'tighten' all the columns? > > E.G. Column A has data, column B not data, column c has data > Delete column b and move column C to the left > > E.G. AirCode > For my sheet > find last.row with data ' that becomes the base point > find last.column with data ' that becomes a base point > loop through columns & rows > for A to last column > from 1 to last row > if data = null then > delete column currentcolumn > blah blah blah > > Many thanks in advance > > Darren > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From darrend at nimble.com.au Tue Apr 4 09:41:30 2006 From: darrend at nimble.com.au (Darren DICK) Date: Wed, 5 Apr 2006 00:41:30 +1000 Subject: [dba-SQLServer] (no subject) In-Reply-To: Message-ID: <20060404144159.SGOJ3168.omta02ps.mx.bigpond.com@DENZILLAP> Hi Francisco Not my code It's the Export to Excel option from reporting services If it calls a SPROC from its 'home' db then I'd love to know about it But AFAIKT it's all 'internal' - IE no access for me to modify Darren ------------------------------ T: 0424 696 433 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Tuesday, 4 April 2006 11:59 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] (no subject) why not tighten up the sproc or view that drives the report? eliminate nulls or empty values On 4/3/06, Darren DICK wrote: > Hi all > Cross Posted to AccessD list > I am outputting reports to Excel from reporting services (SQL) The > reports have many tables on them with differing column widths When I > output the reports to Excel I find many columns with no data in them > > Is there a way I can write some VBA and have it determine the last row > on the sheet with a value in it determine if there is any data in any > cell from the top to the bottom - if there is no data in the column > delete it. Then 'tighten' all the columns? > > E.G. Column A has data, column B not data, column c has data Delete > column b and move column C to the left > > E.G. AirCode > For my sheet > find last.row with data ' that becomes the base point > find last.column with data ' that becomes a base point loop > through columns & rows > for A to last column > from 1 to last row > if data = null then > delete column currentcolumn > blah blah blah > > Many thanks in advance > > Darren > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Tue Apr 4 10:53:16 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 4 Apr 2006 08:53:16 -0700 Subject: [dba-SQLServer] (no subject) In-Reply-To: <20060404144159.SGOJ3168.omta02ps.mx.bigpond.com@DENZILLAP> References: <20060404144159.SGOJ3168.omta02ps.mx.bigpond.com@DENZILLAP> Message-ID: so when you view your report on the screen, there are no blank rows? On 4/4/06, Darren DICK wrote: > Hi Francisco > > Not my code > It's the Export to Excel option from reporting services > If it calls a SPROC from its 'home' db then I'd love to know about it > But AFAIKT it's all 'internal' - IE no access for me to modify > > > > > Darren > ------------------------------ > T: 0424 696 433 > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia > Sent: Tuesday, 4 April 2006 11:59 PM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] (no subject) > > why not tighten up the sproc or view that drives the report? eliminate nulls or > empty values > > > On 4/3/06, Darren DICK wrote: > > Hi all > > Cross Posted to AccessD list > > I am outputting reports to Excel from reporting services (SQL) The > > reports have many tables on them with differing column widths When I > > output the reports to Excel I find many columns with no data in them > > > > Is there a way I can write some VBA and have it determine the last row > > on the sheet with a value in it determine if there is any data in any > > cell from the top to the bottom - if there is no data in the column > > delete it. Then 'tighten' all the columns? > > > > E.G. Column A has data, column B not data, column c has data Delete > > column b and move column C to the left > > > > E.G. AirCode > > For my sheet > > find last.row with data ' that becomes the base point > > find last.column with data ' that becomes a base point loop > > through columns & rows > > for A to last column > > from 1 to last row > > if data = null then > > delete column currentcolumn > > blah blah blah > > > > Many thanks in advance > > > > Darren > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > > -- > -Francisco > http://pcthis.blogspot.com |PC news with out the jargon! > http://sqlthis.blogspot.com | Tsql and More... > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From newsgrps at dalyn.co.nz Tue Apr 4 18:58:11 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 05 Apr 2006 11:58:11 +1200 Subject: [dba-SQLServer] [AccessD] Optimizing Stored Procedures and Views In-Reply-To: References: Message-ID: <7.0.1.0.0.20060405111333.01b77b28@dalyn.co.nz> Thanks to all who have responded. I am working my way through the suggestions. I downloaded the trial version of Red-Gate SQL comparison. It only showed some extended properties as being different in the various tables, views and sprocs. I synchronized the objects but the problem still persists. Using Ken's Test by Destruction method I identified the problem view as highlighted below: SELECT dbo.vwAgedDebtorGet.CustomerID, dbo.vwAgedDebtorGet.StatementID, dbo.vwAgedDebtorGet.AccountNo, dbo.vwAgedDebtorGet.CustName, dbo.vwAgedDebtorGet.StatementDate, dbo.vwAgedDebtorGet.StatementNumber, dbo.vwAgedDebtorGet.AccFreq, dbo.vwAgedDebtorGet.CurrentMth, dbo.vwAgedDebtorGet.OneMonth, dbo.vwAgedDebtorGet.TwoMonths, dbo.vwAgedDebtorGet.ThreeMonths, dbo.vwAgedDebtorGet.NoOverdueNote, dbo.vwAgedDebtorReceipt.NetReceipts, dbo.vwAgedDebtorReceipt.GJCredit, dbo.vwAgedDebtorReceiptInv.NetReceiptsInv, dbo.vwAgedDebtorReceiptInv.GJCreditInv, dbo.vwAgedDebtorGet.MGrpIDNo, dbo.vwAgedDebtorGet.DDRegistered, dbo.vwAgedDebtorGet.DDFrequency, dbo.vwAgedDebtorGet.PayArrange, dbo.vwAgedDebtorReceiptNotPost.ReceiptNotPost AS ReceiptsNotPosted, dbo.vwAgedDebtorGet.VIPCust, dbo.vwAgedDebtorGet.AccStatus FROM dbo.vwAgedDebtorGet INNER JOIN dbo.vwAgedDebtorGetLastStatDate ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorGetLastStatDate.CustIDNo AND dbo.vwAgedDebtorGet.StatementDate = dbo.vwAgedDebtorGetLastStatDate.StatementDate LEFT OUTER JOIN dbo.vwAgedDebtorReceipt ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorReceipt.CustIDNo AND dbo.vwAgedDebtorGet.StatementNumber = dbo.vwAgedDebtorReceipt.StatNum LEFT OUTER JOIN dbo.vwAgedDebtorReceiptInv ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorReceiptInv.CustIDNo AND dbo.vwAgedDebtorGet.StatementNumber = dbo.vwAgedDebtorReceiptInv.InvNum LEFT OUTER JOIN dbo.vwAgedDebtorReceiptNotPost ON dbo.vwAgedDebtorGet.CustomerID = dbo.vwAgedDebtorReceiptNotPost.CustIDNo This is the whole of the sproc - there are no other where clauses etc. When I delete this join (and the fields in the SELECT section from the dbo.vwAgedDebtorReceiptInv view) then the sproc runs in 4 seconds and returns 680 rows. When I run the dbo.vwAgedDebtorReceiptInv view within Access it returns 2780 rows in a couple of second. Ken asked if the views are indexed. I couldn't see any properties in SQL2000 in the view for indexing. The StatementNumber and InvNum fields in the underlying tables are indexed I have used the dbo.vwAgedDebtorReceiptInv view in other sprocs and they work in an acceptable time. In all other cases though the join is to a table, not another view. (However, remember that the same sproc runs fine in the second database). The dbo.vwAgedDebtorReceiptInv is not a simple view: SELECT TOP 100 PERCENT SUM(ROUND((CASE WHEN TranCode = 'CR' THEN CASE WHEN TranAmt < 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) + SUM(ROUND((CASE WHEN TranCode = 'CN' THEN CASE WHEN TranAmt < 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) + SUM(ROUND((CASE WHEN TranCode = 'RR' THEN CASE WHEN TranAmt > 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) AS NetReceiptsInv, SUM(ROUND((CASE WHEN TranCode = 'CR' THEN CASE WHEN TranAmt < 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) AS CRReceiptsInv, SUM(ROUND((CASE WHEN TranCode = 'CN' THEN CASE WHEN TranAmt < 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) AS CNReceiptsInv, SUM(ROUND((CASE WHEN TranCode = 'RR' THEN CASE WHEN TranAmt > 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) AS RevReceiptsInv, SUM(ROUND((CASE WHEN TranCode = 'GJ' THEN CASE WHEN TranAmt < 0 THEN TranAmt ELSE 0 END ELSE 0 END) * CASE WHEN GSTPayable = 1 THEN (1 + GSTRate) ELSE 1 END, 2)) AS GJCreditInv, dbo.tblGenJournal.LinkIDNo, dbo.tblGenJournal.CustIDNo, dbo.tblCustInvoice.InvoiceNumber - 1 AS InvNum, dbo.tblCustInvoice.InvoiceDate FROM dbo.tblGenJournal INNER JOIN dbo.tblCustInvoice ON dbo.tblGenJournal.LinkIDNo = dbo.tblCustInvoice.InvoiceID WHERE (dbo.tblGenJournal.TranType = 1) GROUP BY dbo.tblGenJournal.LinkIDNo, dbo.tblGenJournal.CustIDNo, dbo.tblCustInvoice.InvoiceNumber - 1, dbo.tblCustInvoice.InvoiceDate HAVING (dbo.tblCustInvoice.InvoiceNumber - 1 > 0) ORDER BY dbo.tblGenJournal.LinkIDNo David At 4/04/2006, you wrote: >David, > > > I have a stored procedure that is based on a number of views ... > > In the SQL database that this was developed in it runs fine > > (in about 30 seconds). However, when I script the objects and > > restore them into the second database, the same stored procedure > > runs for over 10 minutes... > >It is a little hard to give advice without more information: > >* Are the views simple views (SELECTs against a single table) or complex >(SELECTs against multiple tables)? >* Are the views indexed? >* Are you returning a subset of the records in your procedure, or >everything? (In other words, is there a WHERE clause you are not showing >us?) >* What is the distribution of the data? For instance, does >vwAgedDebtorGet return greatly more or less records than >vwAgedDebtorGetLastStatDate? > >Even without answers to these questions, there is a diagnostic method >that will almost certainly work: Test by Destruction. To do this: > >1. Make copies of your proc on both databases. >2. On the copies, remove one view at a time from each proc. (start from >the bottom) >3. Recreate both procs, and test the response time. >4. Repeat steps 2-3 until your slower proc performs as expected, or you >run out of views > >The last view you removed, or the last one standing, is the one that is >introducing the slowdown. Investigate that view, because something about >it is different between the two databases, or the data it is querying is >different. If the view is complex, you can test it by destruction using >the process outlined above to find the table or join that is causing the >problem. > >Test by Destruction is a generic, simple way of isolating problems in >complex queries. > >-Ken >-- >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com From newsgrps at dalyn.co.nz Tue Apr 4 19:04:14 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 05 Apr 2006 12:04:14 +1200 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: References: <7.0.1.0.0.20060403144712.01abbb48@dalyn.co.nz> Message-ID: <7.0.1.0.0.20060405115738.01b72f78@dalyn.co.nz> The server is just my local machine not connected to any network. However, the same results occur on the networked server on the Client site. Physical Memory 512MB Virtual Memory 2 GB As far as "hdd, raid, and of course... index defrags" are concerned, where do I find the information on these? David At 4/04/2006, Francisco Tapia wrote: >David, > I might have missed your first post. I'm curious to know what is >your server configuration like?, memory, hdd, raid, and of course... >index defrags. From michael at ddisolutions.com.au Tue Apr 4 21:05:08 2006 From: michael at ddisolutions.com.au (Michael Maddison) Date: Wed, 5 Apr 2006 12:05:08 +1000 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views Message-ID: <59A61174B1F5B54B97FD4ADDE71E7D0116A486@ddi-01.DDI.local> David, >From BOL DBCC INDEXDEFRAG (Northwind, Orders, CustomersOrders) GO Did you compare execution plans? regards Michael Maddison DDI Solutions Pty Ltd michael at ddisolutions.com.au Bus: 0260400620 Mob: 0412620497 www.ddisolutions.com.au -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Wednesday, 5 April 2006 10:04 AM To: accessd at databaseadvisors.com; dba-SQLServer at databaseadvisors.com Subject: Re: [dba-SQLServer] Optimizing Stored Procedures and Views The server is just my local machine not connected to any network. However, the same results occur on the networked server on the Client site. Physical Memory 512MB Virtual Memory 2 GB As far as "hdd, raid, and of course... index defrags" are concerned, where do I find the information on these? David At 4/04/2006, Francisco Tapia wrote: >David, > I might have missed your first post. I'm curious to know what is >your server configuration like?, memory, hdd, raid, and of course... >index defrags. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Tue Apr 4 22:37:11 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 4 Apr 2006 20:37:11 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: <7.0.1.0.0.20060405115738.01b72f78@dalyn.co.nz> References: <7.0.1.0.0.20060403144712.01abbb48@dalyn.co.nz> <7.0.1.0.0.20060405115738.01b72f78@dalyn.co.nz> Message-ID: To get your server configuration, you can run the scripts listed on my blog here, http://sqlthis.blogspot.com/2005/02/how-is-your-server-configured.html to get the indexes for the table youre looking at run the following DBCC SHOWCONTIG ('tbl_YourTableName') with fast,ALL_INDEXES (renaming the "tbl_YourTableName" of course) On 4/4/06, David Emerson wrote: > The server is just my local machine not connected to any > network. However, the same results occur on the networked server on > the Client site. > > Physical Memory 512MB > Virtual Memory 2 GB > > As far as "hdd, raid, and of course... index defrags" are concerned, > where do I find the information on these? > > David > > > At 4/04/2006, Francisco Tapia wrote: > >David, > > I might have missed your first post. I'm curious to know what is > >your server configuration like?, memory, hdd, raid, and of course... > >index defrags. > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From darrend at nimble.com.au Tue Apr 4 22:52:40 2006 From: darrend at nimble.com.au (Darren DICK) Date: Wed, 5 Apr 2006 13:52:40 +1000 Subject: [dba-SQLServer] (no subject) In-Reply-To: Message-ID: <20060405035254.RBAC17345.omta04ps.mx.bigpond.com@DENZILLAP> Yep on screen it's beautiful When you export to Excel lots of hidden columns with no data I know how it happens - I just don't have a solution for it Though Shamil form AccessD wrote me lovely piece of code to remove Certain columns with no data I just need to incorporate that code after (or just before) the Excel doc is created Darren ------------------------------ T: 0424 696 433 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Wednesday, 5 April 2006 1:53 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] (no subject) so when you view your report on the screen, there are no blank rows? On 4/4/06, Darren DICK wrote: > Hi Francisco > > Not my code > It's the Export to Excel option from reporting services If it calls a > SPROC from its 'home' db then I'd love to know about it But AFAIKT > it's all 'internal' - IE no access for me to modify > > > > Darren > ------------------------------ > T: 0424 696 433 > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > Francisco Tapia > Sent: Tuesday, 4 April 2006 11:59 PM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] (no subject) > > why not tighten up the sproc or view that drives the report? eliminate > nulls or empty values > > > On 4/3/06, Darren DICK wrote: > > Hi all > > Cross Posted to AccessD list > > I am outputting reports to Excel from reporting services (SQL) The > > reports have many tables on them with differing column widths When I > > output the reports to Excel I find many columns with no data in them > > > > Is there a way I can write some VBA and have it determine the last > > row on the sheet with a value in it determine if there is any data > > in any cell from the top to the bottom - if there is no data in the > > column delete it. Then 'tighten' all the columns? > > > > E.G. Column A has data, column B not data, column c has data Delete > > column b and move column C to the left > > > > E.G. AirCode > > For my sheet > > find last.row with data ' that becomes the base point > > find last.column with data ' that becomes a base point loop > > through columns & rows > > for A to last column > > from 1 to last row > > if data = null then > > delete column currentcolumn > > blah blah blah > > > > Many thanks in advance > > > > Darren > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > > -- > -Francisco > http://pcthis.blogspot.com |PC news with out the jargon! > http://sqlthis.blogspot.com | Tsql and More... > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Wed Apr 5 10:36:41 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 5 Apr 2006 08:36:41 -0700 Subject: [dba-SQLServer] (no subject) In-Reply-To: <20060405035254.RBAC17345.omta04ps.mx.bigpond.com@DENZILLAP> References: <20060405035254.RBAC17345.omta04ps.mx.bigpond.com@DENZILLAP> Message-ID: Sometimes re-sizing a control can fix that, are you using the table or matrix control? On 4/4/06, Darren DICK wrote: > Yep on screen it's beautiful > When you export to Excel lots of hidden columns with no data > I know how it happens - I just don't have a solution for it > > Though Shamil form AccessD wrote me lovely piece of code to remove > Certain columns with no data > > I just need to incorporate that code after (or just before) the Excel doc is > created > > Darren > ------------------------------ > T: 0424 696 433 > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia > Sent: Wednesday, 5 April 2006 1:53 AM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] (no subject) > > so when you view your report on the screen, there are no blank rows? > > On 4/4/06, Darren DICK wrote: > > Hi Francisco > > > > Not my code > > It's the Export to Excel option from reporting services If it calls a > > SPROC from its 'home' db then I'd love to know about it But AFAIKT > > it's all 'internal' - IE no access for me to modify > > > > > > > > Darren > > ------------------------------ > > T: 0424 696 433 > > > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > > Francisco Tapia > > Sent: Tuesday, 4 April 2006 11:59 PM > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] (no subject) > > > > why not tighten up the sproc or view that drives the report? eliminate > > nulls or empty values > > > > > > On 4/3/06, Darren DICK wrote: > > > Hi all > > > Cross Posted to AccessD list > > > I am outputting reports to Excel from reporting services (SQL) The > > > reports have many tables on them with differing column widths When I > > > output the reports to Excel I find many columns with no data in them > > > > > > Is there a way I can write some VBA and have it determine the last > > > row on the sheet with a value in it determine if there is any data > > > in any cell from the top to the bottom - if there is no data in the > > > column delete it. Then 'tighten' all the columns? > > > > > > E.G. Column A has data, column B not data, column c has data Delete > > > column b and move column C to the left > > > > > > E.G. AirCode > > > For my sheet > > > find last.row with data ' that becomes the base point > > > find last.column with data ' that becomes a base point loop > > > through columns & rows > > > for A to last column > > > from 1 to last row > > > if data = null then > > > delete column currentcolumn > > > blah blah blah > > > > > > Many thanks in advance > > > > > > Darren > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > > > > > > -- > > -Francisco > > http://pcthis.blogspot.com |PC news with out the jargon! > > http://sqlthis.blogspot.com | Tsql and More... > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > > -- > -Francisco > http://pcthis.blogspot.com |PC news with out the jargon! > http://sqlthis.blogspot.com | Tsql and More... > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From DavidL at sierranevada.com Wed Apr 5 12:55:34 2006 From: DavidL at sierranevada.com (David Lewis) Date: Wed, 5 Apr 2006 10:55:34 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views Message-ID: <00101736F13D774F88C54058CB2663C8483C02@celebration.sierranevada.corp> Well, there is a lot there to begin to look through... One thing that sticks out is the "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the "ORDER BY" clause and you will do much to streamline the execution of the view. Also consider making as many of the queries covered as possible by either adding indexes or removing columns from the views that are not needed in the final query. I am not very experienced with streamline execution plans by optimizing joins, but I do try to read what comes my way and I have read that all joins are NOT created equal. Because your joins are relatively complex, it may be that there is much to do in that area. When I find a good reference I will pass it on... D. Lewis From fhtapia at gmail.com Wed Apr 5 17:29:06 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 5 Apr 2006 15:29:06 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: <00101736F13D774F88C54058CB2663C8483C02@celebration.sierranevada.corp> References: <00101736F13D774F88C54058CB2663C8483C02@celebration.sierranevada.corp> Message-ID: If this is a very busy table you can generally use table hints to prevent locking the table, and is generally very fast, simplay add a WITH(NOLOCK) at the end of your table names (not variable tables). On 4/5/06, David Lewis wrote: > Well, there is a lot there to begin to look through... > > One thing that sticks out is the > > "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the > "ORDER BY" clause and you will do much to streamline the execution of > the view. Also consider making as many of the queries covered as > possible by either adding indexes or removing columns from the views > that are not needed in the final query. > > I am not very experienced with streamline execution plans by optimizing > joins, but I do try to read what comes my way and I have read that all > joins are NOT created equal. Because your joins are relatively complex, > it may be that there is much to do in that area. When I find a good > reference I will pass it on... > > D. Lewis > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From darrend at nimble.com.au Wed Apr 5 17:29:06 2006 From: darrend at nimble.com.au (Darren DICK) Date: Thu, 6 Apr 2006 08:29:06 +1000 Subject: [dba-SQLServer] (no subject) In-Reply-To: Message-ID: <20060405222936.GHIP25409.omta05sl.mx.bigpond.com@DENZILLAP> Hi Francisco I have resized all controls to be 2cm, 4cm 6 or 8 cm wide Both on the report and in the tables Nothing else I have really resized all controls to be those sizes and once we export to Excel - I get pretty even results But if I add another table and use the same or similar width structure I realise in reality a control could be 2.000000345cm wide and the one below it is in reality 2.000000346cm wide - so we end up with a new column once we export to Excel Basically the problem comes when I add more than 1 table I should have been more precise in my original post And it's all just text boxes and tables - no matrixes yet - Darren ------------------------------ T: 0424 696 433 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Thursday, 6 April 2006 1:37 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] (no subject) Sometimes re-sizing a control can fix that, are you using the table or matrix control? On 4/4/06, Darren DICK wrote: > Yep on screen it's beautiful > When you export to Excel lots of hidden columns with no data I know > how it happens - I just don't have a solution for it > > Though Shamil form AccessD wrote me lovely piece of code to remove > Certain columns with no data > > I just need to incorporate that code after (or just before) the Excel > doc is created > > Darren > ------------------------------ > T: 0424 696 433 > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > Francisco Tapia > Sent: Wednesday, 5 April 2006 1:53 AM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] (no subject) > > so when you view your report on the screen, there are no blank rows? > > On 4/4/06, Darren DICK wrote: > > Hi Francisco > > > > Not my code > > It's the Export to Excel option from reporting services If it calls > > a SPROC from its 'home' db then I'd love to know about it But > > AFAIKT it's all 'internal' - IE no access for me to modify > > > > > > > > Darren > > ------------------------------ > > T: 0424 696 433 > > > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > > Francisco Tapia > > Sent: Tuesday, 4 April 2006 11:59 PM > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] (no subject) > > > > why not tighten up the sproc or view that drives the report? > > eliminate nulls or empty values > > > > > > On 4/3/06, Darren DICK wrote: > > > Hi all > > > Cross Posted to AccessD list > > > I am outputting reports to Excel from reporting services (SQL) The > > > reports have many tables on them with differing column widths When > > > I output the reports to Excel I find many columns with no data in > > > them > > > > > > Is there a way I can write some VBA and have it determine the last > > > row on the sheet with a value in it determine if there is any data > > > in any cell from the top to the bottom - if there is no data in > > > the column delete it. Then 'tighten' all the columns? > > > > > > E.G. Column A has data, column B not data, column c has data > > > Delete column b and move column C to the left > > > > > > E.G. AirCode > > > For my sheet > > > find last.row with data ' that becomes the base point > > > find last.column with data ' that becomes a base point loop > > > through columns & rows > > > for A to last column > > > from 1 to last row > > > if data = null then > > > delete column currentcolumn > > > blah blah blah > > > > > > Many thanks in advance > > > > > > Darren > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > > > > > > -- > > -Francisco > > http://pcthis.blogspot.com |PC news with out the jargon! > > http://sqlthis.blogspot.com | Tsql and More... > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > > -- > -Francisco > http://pcthis.blogspot.com |PC news with out the jargon! > http://sqlthis.blogspot.com | Tsql and More... > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From newsgrps at dalyn.co.nz Fri Apr 7 16:11:24 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Sat, 08 Apr 2006 09:11:24 +1200 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: References: <00101736F13D774F88C54058CB2663C8483C02@celebration.sierranevada.corp> Message-ID: <7.0.1.0.0.20060408090841.01b31c00@dalyn.co.nz> Dear all, Thanks for all your suggestions. I was given 18 hours notice to turn up to our hospital for a pacemaker replacement (I wore out the old one - too much late night/early morning programming). Operation successful but I feel as if someone hit my shoulder with a sledgehammer (which they well might have done considering the banging that was going on during the operation). Hope to be back on deck next week to follow up the suggestions. David At 6/04/2006, you wrote: >If this is a very busy table you can generally use table hints to >prevent locking the table, and is generally very fast, simplay add a >WITH(NOLOCK) at the end of your table names (not variable tables). > > >On 4/5/06, David Lewis wrote: > > Well, there is a lot there to begin to look through... > > > > One thing that sticks out is the > > > > "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the > > "ORDER BY" clause and you will do much to streamline the execution of > > the view. Also consider making as many of the queries covered as > > possible by either adding indexes or removing columns from the views > > that are not needed in the final query. > > > > I am not very experienced with streamline execution plans by optimizing > > joins, but I do try to read what comes my way and I have read that all > > joins are NOT created equal. Because your joins are relatively complex, > > it may be that there is much to do in that area. When I find a good > > reference I will pass it on... > > > > D. Lewis > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > >-- >-Francisco >http://pcthis.blogspot.com |PC news with out the jargon! >http://sqlthis.blogspot.com | Tsql and More... >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From fhtapia at gmail.com Fri Apr 7 16:41:35 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 7 Apr 2006 14:41:35 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: <7.0.1.0.0.20060408090841.01b31c00@dalyn.co.nz> References: <00101736F13D774F88C54058CB2663C8483C02@celebration.sierranevada.corp> <7.0.1.0.0.20060408090841.01b31c00@dalyn.co.nz> Message-ID: Yikes, This query was tough on you. I hope you get better soon! On 4/7/06, David Emerson wrote: > Dear all, > > Thanks for all your suggestions. I was given 18 hours notice to turn > up to our hospital for a pacemaker replacement (I wore out the old > one - too much late night/early morning programming). > > Operation successful but I feel as if someone hit my shoulder with a > sledgehammer (which they well might have done considering the banging > that was going on during the operation). > > Hope to be back on deck next week to follow up the suggestions. > > David > > At 6/04/2006, you wrote: > >If this is a very busy table you can generally use table hints to > >prevent locking the table, and is generally very fast, simplay add a > >WITH(NOLOCK) at the end of your table names (not variable tables). > > > > > >On 4/5/06, David Lewis wrote: > > > Well, there is a lot there to begin to look through... > > > > > > One thing that sticks out is the > > > > > > "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the > > > "ORDER BY" clause and you will do much to streamline the execution of > > > the view. Also consider making as many of the queries covered as > > > possible by either adding indexes or removing columns from the views > > > that are not needed in the final query. > > > > > > I am not very experienced with streamline execution plans by optimizing > > > joins, but I do try to read what comes my way and I have read that all > > > joins are NOT created equal. Because your joins are relatively complex, > > > it may be that there is much to do in that area. When I find a good > > > reference I will pass it on... > > > > > > D. Lewis > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > > > > > >-- > >-Francisco > >http://pcthis.blogspot.com |PC news with out the jargon! > >http://sqlthis.blogspot.com | Tsql and More... > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From cfoust at infostatsystems.com Fri Apr 7 17:28:51 2006 From: cfoust at infostatsystems.com (Charlotte Foust) Date: Fri, 7 Apr 2006 15:28:51 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views Message-ID: Sounds like they replaced your leads as well as the unit itself. I got off lightly this time, they just unzipped my chest pocket and clipped in a new pacer, no need to replace any of the wiring. I felt pretty seedy for a week, but you will feel much better with a lot of rest ... And no early morning/late night programming! LOL Charlotte Foust -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Friday, April 07, 2006 2:11 PM To: dba-sqlserver at databaseadvisors.com; accessd at databaseadvisors.com Subject: Re: [dba-SQLServer] Optimizing Stored Procedures and Views Dear all, Thanks for all your suggestions. I was given 18 hours notice to turn up to our hospital for a pacemaker replacement (I wore out the old one - too much late night/early morning programming). Operation successful but I feel as if someone hit my shoulder with a sledgehammer (which they well might have done considering the banging that was going on during the operation). Hope to be back on deck next week to follow up the suggestions. David At 6/04/2006, you wrote: >If this is a very busy table you can generally use table hints to >prevent locking the table, and is generally very fast, simplay add a >WITH(NOLOCK) at the end of your table names (not variable tables). > > >On 4/5/06, David Lewis wrote: > > Well, there is a lot there to begin to look through... > > > > One thing that sticks out is the > > > > "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the > > "ORDER BY" clause and you will do much to streamline the execution > > of the view. Also consider making as many of the queries covered as > > possible by either adding indexes or removing columns from the views > > that are not needed in the final query. > > > > I am not very experienced with streamline execution plans by > > optimizing joins, but I do try to read what comes my way and I have > > read that all joins are NOT created equal. Because your joins are > > relatively complex, it may be that there is much to do in that area. > > When I find a good reference I will pass it on... > > > > D. Lewis > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > >-- >-Francisco >http://pcthis.blogspot.com |PC news with out the jargon! >http://sqlthis.blogspot.com | Tsql and More... >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jlawrenc1 at shaw.ca Fri Apr 7 22:08:31 2006 From: jlawrenc1 at shaw.ca (Jim Lawrence) Date: Fri, 07 Apr 2006 20:08:31 -0700 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: <7.0.1.0.0.20060408090841.01b31c00@dalyn.co.nz> Message-ID: <0IXD00CO1VDAW9Y0@l-daemon> David: It hard when you live a double life; same person just work twice as long as most. I am glad to hear your operation was a success. Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Friday, April 07, 2006 2:11 PM To: dba-sqlserver at databaseadvisors.com; accessd at databaseadvisors.com Subject: Re: [dba-SQLServer] Optimizing Stored Procedures and Views Dear all, Thanks for all your suggestions. I was given 18 hours notice to turn up to our hospital for a pacemaker replacement (I wore out the old one - too much late night/early morning programming). Operation successful but I feel as if someone hit my shoulder with a sledgehammer (which they well might have done considering the banging that was going on during the operation). Hope to be back on deck next week to follow up the suggestions. David At 6/04/2006, you wrote: >If this is a very busy table you can generally use table hints to >prevent locking the table, and is generally very fast, simplay add a >WITH(NOLOCK) at the end of your table names (not variable tables). > > >On 4/5/06, David Lewis wrote: > > Well, there is a lot there to begin to look through... > > > > One thing that sticks out is the > > > > "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the > > "ORDER BY" clause and you will do much to streamline the execution of > > the view. Also consider making as many of the queries covered as > > possible by either adding indexes or removing columns from the views > > that are not needed in the final query. > > > > I am not very experienced with streamline execution plans by optimizing > > joins, but I do try to read what comes my way and I have read that all > > joins are NOT created equal. Because your joins are relatively complex, > > it may be that there is much to do in that area. When I find a good > > reference I will pass it on... > > > > D. Lewis > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > >-- >-Francisco >http://pcthis.blogspot.com |PC news with out the jargon! >http://sqlthis.blogspot.com | Tsql and More... >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From newsgrps at dalyn.co.nz Mon Apr 10 21:43:26 2006 From: newsgrps at dalyn.co.nz (David Emerson) Date: Tue, 11 Apr 2006 14:43:26 +1200 Subject: [dba-SQLServer] Optimizing Stored Procedures and Views In-Reply-To: References: <00101736F13D774F88C54058CB2663C8483C02@celebration.sierranevada.corp> <7.0.1.0.0.20060408090841.01b31c00@dalyn.co.nz> Message-ID: <7.0.1.0.0.20060411144125.01a71bf8@dalyn.co.nz> Dear All, The problem was solved by storing the data from the view that caused the problem into a temporary table, then basing the main procedure on the new table. Thanks all for your help. David At 8/04/2006, you wrote: >Yikes, > This query was tough on you. I hope you get better soon! > >On 4/7/06, David Emerson wrote: > > Dear all, > > > > Thanks for all your suggestions. I was given 18 hours notice to turn > > up to our hospital for a pacemaker replacement (I wore out the old > > one - too much late night/early morning programming). > > > > Operation successful but I feel as if someone hit my shoulder with a > > sledgehammer (which they well might have done considering the banging > > that was going on during the operation). > > > > Hope to be back on deck next week to follow up the suggestions. > > > > David > > > > At 6/04/2006, you wrote: > > >If this is a very busy table you can generally use table hints to > > >prevent locking the table, and is generally very fast, simplay add a > > >WITH(NOLOCK) at the end of your table names (not variable tables). > > > > > > > > >On 4/5/06, David Lewis wrote: > > > > Well, there is a lot there to begin to look through... > > > > > > > > One thing that sticks out is the > > > > > > > > "SELECT TOP 100 PERCENT" in the underlying view. Remove that and the > > > > "ORDER BY" clause and you will do much to streamline the execution of > > > > the view. Also consider making as many of the queries covered as > > > > possible by either adding indexes or removing columns from the views > > > > that are not needed in the final query. > > > > > > > > I am not very experienced with streamline execution plans by optimizing > > > > joins, but I do try to read what comes my way and I have read that all > > > > joins are NOT created equal. Because your joins are > relatively complex, > > > > it may be that there is much to do in that area. When I find a good > > > > reference I will pass it on... > > > > > > > > D. Lewis > > > > _______________________________________________ > > > > dba-SQLServer mailing list > > > > dba-SQLServer at databaseadvisors.com > > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > > http://www.databaseadvisors.com > > > > > > > > > > > > > > > > >-- > > >-Francisco > > >http://pcthis.blogspot.com |PC news with out the jargon! > > >http://sqlthis.blogspot.com | Tsql and More... > > >_______________________________________________ > > >dba-SQLServer mailing list > > >dba-SQLServer at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > >http://www.databaseadvisors.com > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > >-- >-Francisco >http://pcthis.blogspot.com |PC news with out the jargon! >http://sqlthis.blogspot.com | Tsql and More... >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From kp at sdsonline.net Tue Apr 11 19:04:07 2006 From: kp at sdsonline.net (Kath Pelletti) Date: Wed, 12 Apr 2006 10:04:07 +1000 Subject: [dba-SQLServer] Relationships - Sql Server 2005 Message-ID: <000b01c65dc4$9f8d0430$6601a8c0@office> (Cross posted to AccessD and Access SQL) I am creating the relationships between tables in my new system in Sql Server 2005 (developer, not express). I have found 2 ways to do this: 1). By going into a specific table's keys and editing there, or 2) By dragging ands dropping fields in the database diagran, which I find easier. But from within the database diagram I can't find how to view the properties of the relationship. If I right click I only have the option to delete it. Anyone know a better way as this is taking me ages?? TIA Kath From kp at sdsonline.net Tue Apr 11 19:13:08 2006 From: kp at sdsonline.net (Kath Pelletti) Date: Wed, 12 Apr 2006 10:13:08 +1000 Subject: [dba-SQLServer] Relationships - Sql Server 2005 Message-ID: <001c01c65dc5$e19c86b0$6601a8c0@office> Sorry - just worked it out. (USe F4) doh! Kath From kp at sdsonline.net Wed Apr 12 18:39:49 2006 From: kp at sdsonline.net (Kath Pelletti) Date: Thu, 13 Apr 2006 09:39:49 +1000 Subject: [dba-SQLServer] VB.net reference books - experiences + SQL Server List Message-ID: <001e01c65e8a$6452bec0$6601a8c0@office> (Cross posted to SQl Server and AccessD normal list) I have been learning SQL Server 2005 and vb.net this year......I have found Mike Gunderloy's book "Mastering SQL Server 2005" an absolute god send. I would highly recommend this one to anyone going through this learning curve.... But the book I bought for learning vb.net is not so good - "Visual Basic 2005 - Programmer's reference' by Rod Stephens. It's not too bad - very much like reading the MS help screens - but I am looking for a book which will step me through it - a la Mike's style. Any recommendations? (I know O'Reilly's are good but I am told by my colleague here that that it is more of a reference book.) (While I am posting - it's very quiet on our SQL list for now - is there another list anyone has been using which they would recommend? ______________________________________ Kath Pelletti From michael at ddisolutions.com.au Wed Apr 12 21:36:33 2006 From: michael at ddisolutions.com.au (Michael Maddison) Date: Thu, 13 Apr 2006 12:36:33 +1000 Subject: [dba-SQLServer] VB.net reference books - experiences + SQL ServerList Message-ID: <59A61174B1F5B54B97FD4ADDE71E7D0116A4D7@ddi-01.DDI.local> Hi Kath, http://www.sswug.org/ Its oriented towards dba's rather then developers but its very good. Can't help with the vb.net books. Got my own got to learn C# sharp crisis happening... lol cheers Michael M www.ddisolutions.com.au -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti Sent: Thursday, 13 April 2006 9:40 AM To: Access D SQl Server List; Access D Normal List Subject: [dba-SQLServer] VB.net reference books - experiences + SQL ServerList (Cross posted to SQl Server and AccessD normal list) I have been learning SQL Server 2005 and vb.net this year......I have found Mike Gunderloy's book "Mastering SQL Server 2005" an absolute god send. I would highly recommend this one to anyone going through this learning curve.... But the book I bought for learning vb.net is not so good - "Visual Basic 2005 - Programmer's reference' by Rod Stephens. It's not too bad - very much like reading the MS help screens - but I am looking for a book which will step me through it - a la Mike's style. Any recommendations? (I know O'Reilly's are good but I am told by my colleague here that that it is more of a reference book.) (While I am posting - it's very quiet on our SQL list for now - is there another list anyone has been using which they would recommend? ______________________________________ Kath Pelletti _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From kp at sdsonline.net Wed Apr 12 21:59:08 2006 From: kp at sdsonline.net (Kath Pelletti) Date: Thu, 13 Apr 2006 12:59:08 +1000 Subject: [dba-SQLServer] VB.net reference books - experiences + SQLServerList References: <59A61174B1F5B54B97FD4ADDE71E7D0116A4D7@ddi-01.DDI.local> Message-ID: <00a701c65ea6$3bb02720$6601a8c0@office> Great - thanks Michael. Good luck with the C# crisis..... Kath ----- Original Message ----- From: "Michael Maddison" To: Sent: Thursday, April 13, 2006 12:36 PM Subject: Re: [dba-SQLServer] VB.net reference books - experiences + SQLServerList > > Hi Kath, > > http://www.sswug.org/ > Its oriented towards dba's rather then developers but its very good. > > Can't help with the vb.net books. Got my own got to learn C# sharp > crisis happening... lol > > cheers > > Michael M > > www.ddisolutions.com.au > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Kath > Pelletti > Sent: Thursday, 13 April 2006 9:40 AM > To: Access D SQl Server List; Access D Normal List > Subject: [dba-SQLServer] VB.net reference books - experiences + SQL > ServerList > > (Cross posted to SQl Server and AccessD normal list) > > I have been learning SQL Server 2005 and vb.net this year......I have > found Mike Gunderloy's book "Mastering SQL Server 2005" an absolute god > send. I would highly recommend this one to anyone going through this > learning curve.... > > But the book I bought for learning vb.net is not so good - "Visual Basic > 2005 - Programmer's reference' by Rod Stephens. It's not too bad - very > much like reading the MS help screens - but I am looking for a book > which will step me through it - a la Mike's style. Any recommendations? > > (I know O'Reilly's are good but I am told by my colleague here that that > it is more of a reference book.) > > (While I am posting - it's very quiet on our SQL list for now - is there > another list anyone has been using which they would recommend? > > ______________________________________ > Kath Pelletti > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From ebarro at verizon.net Thu Apr 13 10:34:42 2006 From: ebarro at verizon.net (Eric Barro) Date: Thu, 13 Apr 2006 08:34:42 -0700 Subject: [dba-SQLServer] VB.net reference books - experiences + SQL Server List In-Reply-To: <001e01c65e8a$6452bec0$6601a8c0@office> Message-ID: <000301c65f0f$c9ef2900$c767a8c0@amdgcda> I recommend ASP.NET Tips, Tutorial and Code by Mitchell, et al. published by SAMS. Granted the book is geared more towards web-based apps it is nevertheless very helpful in getting the basics down. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti Sent: Wednesday, April 12, 2006 4:40 PM To: Access D SQl Server List; Access D Normal List Subject: [dba-SQLServer] VB.net reference books - experiences + SQL Server List (Cross posted to SQl Server and AccessD normal list) I have been learning SQL Server 2005 and vb.net this year......I have found Mike Gunderloy's book "Mastering SQL Server 2005" an absolute god send. I would highly recommend this one to anyone going through this learning curve.... But the book I bought for learning vb.net is not so good - "Visual Basic 2005 - Programmer's reference' by Rod Stephens. It's not too bad - very much like reading the MS help screens - but I am looking for a book which will step me through it - a la Mike's style. Any recommendations? (I know O'Reilly's are good but I am told by my colleague here that that it is more of a reference book.) (While I am posting - it's very quiet on our SQL list for now - is there another list anyone has been using which they would recommend? ______________________________________ Kath Pelletti _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005 From martyconnelly at shaw.ca Thu Apr 13 11:52:57 2006 From: martyconnelly at shaw.ca (MartyConnelly) Date: Thu, 13 Apr 2006 09:52:57 -0700 Subject: [dba-SQLServer] Developing Time-Oriented Database Applications in SQL, free e-book References: <001e01c65e8a$6452bec0$6601a8c0@office> Message-ID: <443E81E9.9020208@shaw.ca> Came across a good PDF book 500 pages entitled "Developing Time-Oriented Database Applications in SQL" Its free, and you can get it from here: http://www.cs.arizona.edu/people/rts/tdbbook.pdf Foreward by Tim Gray, Microsoft Research: snippet I highly recommend this book to anyone interested in temporal data - either designing and building databases that record information over time, or just understanding the concepts that underlie representing temporal information. This book does an excellent job of organizing and summarizing this important area. -- Marty Connelly Victoria, B.C. Canada From kp at sdsonline.net Mon Apr 17 18:20:31 2006 From: kp at sdsonline.net (Kath Pelletti) Date: Tue, 18 Apr 2006 09:20:31 +1000 Subject: [dba-SQLServer] VB.net reference books - experiences + SQLServer List References: <000301c65f0f$c9ef2900$c767a8c0@amdgcda> Message-ID: <003801c66275$8649b170$6601a8c0@office> Thanks Eric Kath ----- Original Message ----- From: "Eric Barro" To: Sent: Friday, April 14, 2006 1:34 AM Subject: Re: [dba-SQLServer] VB.net reference books - experiences + SQLServer List >I recommend ASP.NET Tips, Tutorial and Code by Mitchell, et al. published >by > SAMS. Granted the book is geared more towards web-based apps it is > nevertheless very helpful in getting the basics down. > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Kath > Pelletti > Sent: Wednesday, April 12, 2006 4:40 PM > To: Access D SQl Server List; Access D Normal List > Subject: [dba-SQLServer] VB.net reference books - experiences + SQL Server > List > > (Cross posted to SQl Server and AccessD normal list) > > I have been learning SQL Server 2005 and vb.net this year......I have > found > Mike Gunderloy's book "Mastering SQL Server 2005" an absolute god send. I > would highly recommend this one to anyone going through this learning > curve.... > > But the book I bought for learning vb.net is not so good - "Visual Basic > 2005 - Programmer's reference' by Rod Stephens. It's not too bad - very > much > like reading the MS help screens - but I am looking for a book which will > step me through it - a la Mike's style. Any recommendations? > > (I know O'Reilly's are good but I am told by my colleague here that that > it > is more of a reference book.) > > (While I am posting - it's very quiet on our SQL list for now - is there > another list anyone has been using which they would recommend? > > ______________________________________ > Kath Pelletti > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005 > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005 > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From artful at rogers.com Wed Apr 19 05:58:18 2006 From: artful at rogers.com (Arthur Fuller) Date: Wed, 19 Apr 2006 06:58:18 -0400 Subject: [dba-SQLServer] On Elephant Capture In-Reply-To: Message-ID: <003601c663a0$2add6f30$8e01a8c0@Camelot.com> The CEO mandates the capture of an elephant. The C programmer says: "Go to the Cape, walk the collection upwards, catch every animal, and discard the ones that are not elephants." The SQL programmer says: "Select * From Animals Where Trunk = True And Size = Huge And Legs = 4." The marketing guy says: "Catch a rabbit, paint it grey and call it a desktop elephant." Arthur