Hi,
I created a view on two huge tables. I tried to run a simple SELECT statement on this view and it took me several hours to obtain the result. How can I improve the performance of a view? The view should make use of the indexes built in both table, am I right? Thanks.
"Cursor provide row-by-row level processing and it will store the result sets in 'TEMPDB' database".
(Because of this) or (By using Cursor in Triggers or Stored Procedures) the performance will increase or performance will come down?. I am thankful if I get a good reason for this?
I'll just throw my question: how could I increase SSIS-performance?
I have a really heavy job with thousands of records my base selection, then I perform some lookups (I replaced most of them by sql) and derived columns (again, I replaced as much as possible by sql). Finally, after a slowly changing dimension task, I do update/insert on a given table. Is there a trick to speed up lookups and inserts (something like manipulating the buffer sizes - just asking). Fact is that I replaced a script task by pure sql-joins and gained 6 of the 12 hours this job took.
I am writing an ASP based application that creates a dynamic querry and then executes it and displays results. I was thinking about writing a stored procedure to increase performance. How much can the SP help me boost querry responce time ???
I have 3 tables (A, B, C) with milions of records (A ca 5 milions, B and C ca 10 milions). I have created a join betwenn them
select some fields (A, B, C) FROM A as a JOIN B as B on a.a1 = b.a1 and a.a2 = b.a2 JOIN C as c ON b.b1 = c.b1 and b.b2 = c.b2 Where fieldtime <= date/time
But it takes to much time: aftre 2 hours and half is still running.
Dear all, I'm using SQL Server 2005 Standard Edetion. I have the following stored procedure that is executed against two tables (RecrodedCalls) and (RecordedCallsTags) The table RecordedCalls has more than 10000000 Records and RecordedCallsTags is about 7500000 Records Now the lines marked in baby blue are dynamic (Dynamic where statement) that varies every time this stored procedure is executed, may it contains 7 columns in condetion statement or may it contains 10 columns, or 2 coulmns.....etc Now I want to create non-clustered indexes on the columns used in the where statement, THE DTA suggests different indexing whenever the where statement changes. So what is the right way to created indexes, to create one index on all the columns once, or to create separate indexes on each columns, sometimes the DTA suggests 5 columns together at one if I€™m using 5 conditions, I can€™t accumulate all the possible indexes hence the where statement always vary from situation to situation, below the SP:
CREATE TABLE #tempLookups (ID int identity(0,1),Code NVARCHAR(100),NameE NVARCHAR(500),NameA NVARCHAR(500))
CREATE TABLE #tempTable (ID int identity(0,1),TypesCount INT,CallsType NVARCHAR(50))
INSERT INTO #tempLookups SELECT Code, NameE, NameA FROM lookups WHERE [Type] = 'CALLTYPES' ORDER BY Ordering ASC
INSERT INTO #tempTable SELECT COUNT(DISTINCT(RecordedCalls.ID)) As TypesCount,RecordedCalls.CallType as CallsType
FROM RecordedCalls LEFT OUTER JOIN RecordedCallsTags ON RecordedCalls.ID = RecordedCallsTags.CallID
WHERE RecordedCalls.ID <= '9369907'
AND (RecordedCalls.CallDate BETWEEN cast ('01 Jan 1910 00:00:00:000' as datetime ) AND cast ( '01 Jan 2210 00:00:00:000' as datetime ))
AND (RecordedCalls.Duration BETWEEN 0 AND 1000000)
AND RecordedCalls.ChannelID NOT IN('62061','62062','62063','62064','64110','64111','64112','64113','64114','69860','69861','69862','69863','69866','69867','69868')
AND RecordedCalls.ServerID NOT IN('2')
AND RecordedCalls.AgentID NOT IN('1000010000')
AND (RecordedCallsTags.TagID is null OR RecordedCallsTags.TagID NOT IN('100','200'))
AND RecordedCalls.IsDeleted='false'
GROUP BY RecordedCalls.CallType
SELECT IsNull(#tempTable.TypesCount, 0) AS TypesCount, CASE('English')
WHEN 'Arabic' THEN #tempLookups.NameA
ELSE #tempLookups.NameE
END AS CallsType FROM
#tempTable RIGHT OUTER JOIN #tempLookups ON #tempTable.CallsType = #tempLookups.Code
DROP TABLE #tempLookups
DROP TABLE #tempTable
Thanks all, Tayseer
Any suggestions how to create efficient indexes??!!
I have a select statement (that joins 5 tables) and performs fine (when I execute with an additional 'and' statement that uses the 'like' keyword.)
select f1, f2, f3...f10 from table1, table2, .. ,table5 where table1.f3= table4.f4 and ... ... ... and table2.f7 = table1.f4 and table4.f4 like 'MYNAME%'
When I create a view with all of the statement except the last:
create view myview as select f1, f2, f3...f10 from table1, table2, .. ,table5 where table1.f3= table4.f4 and ... ... ... and table2.f7 = table1.f4
and then when I say
select * from myview where f4 like 'MYNAME%'
the performance tanks. The query plan completely changes and the resoponse time slows down 100+ times.
I know views are bad, but I am using PeopleSoft and I need to make this view work. Any ideas how?
I have a view on 5 tables. The first [tblOrder] 62000 records The second joined on the first [tblOrderRegel] 2140000 records The third joined on the second [tblAssortimentSamenstelling] 5800 records The fourth [tblArtikelVerpakking] 1650 records And the last also joined on the third [tblAssortiment] 30 records
When I use the next query SELECT * FROM [dbBIBSMonitor].[dbo].[vwOrderRegel_1] WHERE IDOrder in(SELECT IDOrder FROM [vwOrder] WHERE IDRelatie = 6) GO
It will take more than 60 seconds before the resuld is there
The sub select 'SELECT IDOrder FROM [vwOrder] WHERE IDRelatie = 6' returns a list of ID's. When I make the same select with this ID's instead of the sub select the result returns in 1 second
In the first select I have on all tables en index SCAN on the primairy Index with Hash Match/Inner Join to match.
In the second select I have on all tables en index SEEK on the primairy Index with Nested loop/Inner Join to match.
For the sub select 'SELECT IDOrder FROM [vwOrder] WHERE IDRelatie = 6' is not the primairy key used but an other Unique index Containing three columns. [IDOrder] (also the primairy Key), [IDStatus] (1, 2 or 3. 90% = 3), and a date field.
In the view on the subselect is an UNION of three selects. SELECT IDOrder, Date_1 From tblOrder WHERE IDStatus = 1 UNION SELECT IDOrder, Date_2 From tblOrder WHERE IDStatus = 2 UNION SELECT IDOrder, Date_2 From tblOrder WHERE IDStatus = 3
Thats the reason he usses the Unique Index
Is using this index the reason that he does not SEEK on the first table (also tblOrder) of the view in my select??? In other words: Does SQL-server can use only 1 index on a table for a SEEK?
I hope somebody can give me an answer on this complex story.
Thanks Jaap
By the way. I have already tried selects with a INNNER JOIN in stead of a sub query and also a corralated sub query.
Hi all,SQL Server 2000 service pack 3 running on Quad zeon windows 2003 serverwith 6GB of ram.A few months ago we split our databases into operational and completeddata...So now instead of doing select * from tblTest, we do select * fromtblTestboth where tblTestboth is a view like this:Select *From Operational.dbo.tbltestUNIONSelect *From Archive.dbo.tbltestThe tables on both databases are heavily indexed but it still takes muchlonger to do the select * from tblTestBoth than it is to doSelect *From Operational.dbo.tbltestUNIONSelect *From Archive.dbo.tbltestCan anyone please tell me why that is? We are starting to get timeoutsregularly...Should I use indexed views even though the data is inserted/updatedmultiple hundres of times per second?Thank you very much in advance for your help...Regards,Auday*** Sent via Developersdex http://www.developersdex.com ***
I have the same database on two different servers. One for production and one for testing. A view that I use runs in less than 2 seconds on the test system, but takes almost 2 minutes on the production server.
What I have noticed is on the test server the view will use an index. The production server ends up scanning a whole table. All indices are the same on both machines for the tables involved and I have updated the statistics. I even went through the process of creating a new table with its indices for the table that is being scanned. Both machines have had service pack 1 installed on them.
I have a view that has been working fine. The data is returned with a second or 2. But in the last 2 or 3 days it will periodically take so long to execute that it will timeout.
I am fairly new to SQL Server 2005, so I am not sure what to check. I am opening the view in Access using an ADP and also in Management Studio.
Also, there are only a couple of users and at the time we are experiencing problems, there really isn't anything going on. No one is trying to run a large query or anything like that.
CREATE VIEW VW_Emplacamentos WITH SCHEMABINDING AS SELECTA.CD_Linha -- This is the unique clustered field A.DT_Emplacamento, A.NR_CNPJ, A.CD_Municipio, A.VL_Potencia, A.VL_CapacidadeCarga, A.NR_QtdPax, A.NR_AnoFabricacao, A.NR_Chassi, A.SG_UF, A.CD_MarcaModelo, A.CD_Procedencia, A.CD_Combustivel, B.NM_Municipio, C.NM_Combustivel, D.NM_MarcaModelo, D.CD_Segmento, D.CD_Fabricante, E.NM_Segmento, F.NM_SubSegmento, G.NM_Fabricante
FROM dbo.TB_Emplacamentos AS A INNER JOIN dbo.TB_Municipio AS B ON A.CD_Municipio = B.CD_Municipio INNER JOIN dbo.TB_Combustivel AS C ON A.CD_Combustivel = C.CD_Combustivel INNER JOIN dbo.TB_ModeloVeiculo AS D ON A.CD_MarcaModelo = D.CD_MarcaModelo INNER JOIN dbo.TB_SegmentoVeiculo AS E ON D.CD_Segmento= E.CD_Segmento INNER JOIN dbo.TB_SubSegmentoVeiculo AS F ON D.CD_SubSegmento = F.CD_SubSegmento INNER JOIN dbo.TB_Fabricante AS G ON D.CD_Fabricante = G.CD_Fabricante
The following query is not getting perfomance. I don't what's going on.
SELECT COUNT(*) FROM VW_Emplacamentos WHERE DT_Emplacamento BETWEEN '20040301' AND '20040316' AND NM_Fabricante = 'VW'
I've created an compost index on the following sequece DT_Emplacamento,NM_Fabricante,NM_Segmento
I recently added several indexed views to a high traffic table (high volume of both inserts and selects) because I needed to have some complicated unique constraints involving columns that allow NULL.
While I didn't notice performance problems at first, it appears to be that the CPU on the SQL Server is getting pegged when more than 10 or 15 simultaneous inserts are happening on the table. This is a quad proc 3Ghz Xeon, so the fact the CPU is hitting 90%+ while doing 15 inserts a second doesn't make sense to me.
Very quickly the sproc that is being repeatedly called by some middle tier components is taking 30+ seconds to execute, eventually causing timeouts. This sproc is very simple. It does a few quick select statements (that take well under 100ms), and then does an insert into the table in question. That's it.
The only thing I can think of is that the overhead of 3 separate indexed views on the table, each of which contains a significant subset of the total rows in the table (550,000+ rows), is causing SQL Server to get swamped trying to keep the indexes up to date.
Does this seem like a possibility? I'm planning on temporarily removing those indexed views to see how it performs without them, although this is dangerous because it creates the potential for invalid data.
Hi all, first of all I shoud mention it that I have posted a similar question in Oracle forum and recieve enough oracle-related feedback and solution, here (http://www.dbforums.com/showthread.php?t=1609238).
Now I want to know if LIKE searches are awful (performance wise) in SQL Server too, do you recommand any solution to enhance it by some indexing twick? I want to avoid using MS index service (if I spell it correctly) as far as I could ;)
Note: We have a lot of LIKE '%abc%' queries at this system.
Greetings,I have 3 servers all running SQL Server 2000 - 8.00.818. Lets callthem parent, child1, and child 2.On parent, I create a view called item as follows:CREATE view Item asselect * from child1.dbchild1.dbo.Item union allselect * from child2.DBChild2.dbo.ItemOn child1 and child2, I have a table "item" with a column named "id"datatype uniqueidentifier (and many other columns). There is anon-clustered index created over column "id".When I connect to the parent server and select from the viewSelect id, col1, col2, …. From item where id =‘280A33E0-5B61-4194-B242-0E184C46BB59'The query is distributed to the children "correctly" (meaning itexecutes entirely (including the where clause) on the children serverand one row is returned to the parent).However, when I select based on a list of idsSelect id, col1, col2, …. From item where id in(‘280A33E0-5B61-4194-B242-0E184C46BB59',‘376FA839-B48A-4599-BC67-25C6820FE105')the plan shows that the entire contents of both children item tables(millions of rows each) are pulled from the children to the parent,and THEN the where criteria is applied.Oddly enough, if I put the list of id's I want into a temp tableselect * from #bv1id------------------------------------280A33E0-5B61-4194-B242-0E184C46BB59376FA839-B48A-4599-BC67-25C6820FE105and thenSelect id, col1, col2, …. From item where id in (select * from #bv1)the query executes with the where criteria applied on the childrendatabases saving millions of rows being copied back to the parentserver.So, I have a hack that works (using the temp table) for this case, butI really don't understand the root cause. After reading online books,in a way I am confused why ANY of the processing is done on thechildren servers. I quote:================================================Remote Query ExecutionSQL Server attempts to delegate as much of the evaluation of adistributed query to the SQL Command Provider as possible. An SQLquery that accesses only the remote tables stored in the provider'sdata source is extracted from the original distributed query andexecuted against the provider. This reduces the number of rowsreturned from the provider and allows the provider to use its indexesin evaluating the query.Considerations that affect how much of the original distributed querygets delegated to the SQL Command Provider include:•The dialect level supported by the SQL Command ProviderSQL Server delegates operations only if they are supported by thespecific dialect level. The dialect levels from highest to lowest are:SQL Server, SQL-92 Entry level, ODBC core, and Jet. The higher thedialect level, the more operations SQL Server can delegate to theprovider.Note The SQL Server dialect level is used when the providercorresponds to a SQL Server linked server.Each dialect level is a superset of the lower levels. Therefore, if anoperation is delegated to a particular level, then Queries involvingthe following are never delegated to a provider and are always it isalso delegated to all higher levels.evaluated locally:•bit•uniqueidentifier================================================This suggests to me that any query having where criteria applied to adatatype uniqueidentifier will have the where criteria applied AFTERdata is returned from the linked server.Any ideas on the root problem, and a better solution to get the queryand all the where criteria applied on the remoted linked server?Thanks,Bernie
I am running A View that INSERTS into #Temp Table - On Only Certain Days the INSERT Speed into #tempDB is so slow. Â Attached snapshot that shows after one minute so many few records are inserted - and it dosent happen every day somedays its very fast.Â
Choose an EEO-1 Classification: Increase all employees salaries that have: the selected EEO-1 classification by 10%.
Increase all employees salaries by 5% Hi! I am new to SQL, but trying to teach myself. I have had lots of help from you guys and appreciate it very much. Today, I was trying to do the following:
In my table of "Employees", I have a column called classifications. I want to increase the salaries of the employees with a classification of EE0-1 by 10%, but I have not figured out to do so.
My second question is how would I increase all employees' salaries by 5%?
Hello all, I have, what i think, is a unique problem that i'm hoping some of you can help me on.
I need to create a record number that is incremented by 1 whenever someone adds a new record to the database. For example, records numbering 1,2,3 are in the database. When the users adds a new record, SQL takes the last recordno, 3 in this case, and adds 1 to it thus producing 4.
Also, i need to have the ability to replace deleted record numbers with new ones. Using the example above, say a user deletes record number 2. Whenever someone adds a new record, sql would see the missing number and assign the new record that number.
I hope i'm making sense here. Does anyone have any ideas about this? Any articles on the web that someone could point me to?
Can someone tell me how I can write a stored procedure that will automatically increment the value of the index by 001? I am attempting to build a table for a menu system and I need to increment the index value of the document by 001 when submitted to the database. I also need to have the script obtain the last index value of the node before inserting new value.
All ideas appreciated.
Sincerely,
Tim
If interested, this requested is based upon an article written by Michael Feranda: http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=7321&lngWId=4
We are getting the following error on an SSIS package: "54 Diagnostic VirtualSQLName DomainUserName Load Daily 859CF005-CB7F-47D8-8432-AE7C074B343C 1A986F18-343F-4424-ABAB-AC6575187DF3 2007-02-14 10:05:42.000 2007-02-14 10:05:42.000 0 0x Based on the system configuration, the maximum concurrent executables are set to 4. "
Basically it is saying the we have reached the maximum amount of executables. How can we increase this value and where?
I am really starting to like CTEs. My only qualm is that you can only use them within the first statement after you declare them. I wish they would remain active for the duration of the sql batch just like everything else (variables,local temp tables, ect). Is there any trick so that you can use them multiple times? Maybe define them as a string and do dynamic sql or something like that? Hopefully (i have not researched the new version of sql server) in SQL Server 2008 the scope has increase. Anyways any help would be appreciated.
I am receiving an error from my ODBC driver “Maximum number of DBPROCESSes already allocated.”
I confirmed that there are 25 connections and that this is the default. This is caused by error message 10029, SQLEDBPS, when the maximum number of simultaneously open DBPROCESS structures exceeds the current setting. I would like to increase this maximum.
I have found only two ways to do this. One is using dbsetmaxprocs using C and the other is using SqlSetMaxProcs using Visual Basic. My problem is that I am interfacing to SQL Server using a third party tool that is doing the lower level programming.
Is there some way that I can increase the maximum number of DB processes for all databases that are part of the SQL Server 7 environment, or can I set this value using a program that is called from a stored procedure?
Any ideas in this area will be greatly appreciated.
Hi all, I encountered error 1105 (Can`t allocate space for object .....) while running a query. I had dump transaction with no log sucessfully and retry running my query but still encounter error 1105.
I had checked my database size and following are the info: Datasize : 2500MB Database size available : 753.39 Log space : 500MB Log space available : 500MB (this was acheive after after dump trans. twice. it was around 480MB before)
Thus looks like the data segment is full!!! I expanded the size of the disk device D on which the segment device A is on by 50MB. When I did a sp_helpdevice D, the expansion is reflected. Next I run sp_extendsegement, A, D. However running sp_helpsegment A doesn`t show that segment A is expanded. Please help!!! How do I expand the size of the segment? (without creating a new disk device, is it possible) Any other way to resolve this problem?
Also how to check if a particular segment is full? eg. the %usage of data/log segment.
I seem to remember that the font size and type can be controlled in SQL Server 6.5 and the process controlls the fonts displayed throughout the program - Enterprise Manager, Query Tool, etc.
I have just re-installed 6.5 and the fonts are way too small.