Quantcast
Channel: SQL Server Database Engine forum
Viewing all 15264 articles
Browse latest View live

SQL chooses a slow plan

$
0
0

I've been chasing around performance issues on this new system for a few weeks now, and it's been frustrating.  I wonder if this is why.

I isolated down to a semi-random little update statement:

update dbo.myhottable
	set anattribute = f.anattribute
from dbo.myhottable t
	inner join dbo.thefulltable f 
		on t.mypk = f.thepk;

This was taking 3 seconds to update 21k rows.  That didn't seem right unless I fell through a time warp to 1994.  Profiler said it was CPU limited, with about 34k logical reads.  CPU limited, three seconds, 21k rows, integer PK to PK, say what?  Even hot, all the data in buffers?

So I did what one never wants to do, I gave SQL a gentle hint:  inner LOOP join.

That did the trick, took the 3.0 seconds down to about 0.3 seconds.  Yes, it increased the logical reads to 120k, but so what?  Also why, but so what?

So, what is the problem here?  Looks like SQL optimized for resources AND NOT TIME.  I've caught it doing this before, but this seems really pathological.

Here's the thing, thefulltable has 6m rows.  The plan scans a 6m index containing thepk and anattribute and does a hash match.  That's a pretty nasty ratio, scanning 6m rows to hash match to 21k.  And it turns out to be a bad idea.

So, why is SQL Server going that way, and is there some magic word I can give it to bias it globally in my direction, CPU/duration?

--

I'm jumping to the conclusion here that I have a lot more of these going on, because some other tricks I usually use have not been succeeding.

I thought I just might have a difficult app here because the data is very lumpy and the statistics would give bad guidance, but in this case it's PK to PK so there should be no ambiguity.

SQL Server 2008 R2 64 bit standard 8gb max memory on 12gb server with 4 cores on Windows Server 2008 standard on VMWare, fwiw.

Josh

ps - I should mention we have maxdop=1 - which I never like to do, but on just four cores, ... hey maybe I did fall through a time warp to 2005 at least!  The thing is, when I override that with an option maxdop=0 guess what, it uses a parallel plan that runs in about 1.5 seconds, IOW the single-thread plan is poor by any standards.  So you ask - if I use both maxdop=0 *and* the LOOP hint, I get the best plan of all, but I probably don't want to be overriding the maxdop.






tracewrite waits averaging over 1000ms

$
0
0

Again looking at waits, and the average wait time for my tracewrites, when running Profiler interactively on my workstation monitoring the engine running on the server, server shows average waits for this of over 1000ms.  Hey that's slow.  Is it always that slow and I never noticed before, or does this indicate a problem?

Possibly a networking problem, which we suspect from time to time, but the asynch_network_io does NOT seem to be a problem, and in general running apps or queries in SSMS seems pretty snappy.

Also, when the profiler is generating these waits, besides the tracewrite it generates oledb waits, it looks like a couple per tracewrite totally almost the same time, although that is less per wait.

Another trace running by script on the server writing to a local file, generates no waits.

SQL 2008 R2 engine on Server 2008 R2 all 64 bit, workstation is Windows 7 Enterprise 64 bit, 1gbps LAN, but I'm not sure where the servers actually are so there must be slower links though tracert doesn't show anything but 1ms delays.

Thanks.

Josh

ps - run interactively ON the server, waits are about 25ms.  very negligible waits in all other categories.  also server is running under VM.



script to get a single email summary of all database and transaction log backups

$
0
0

Hi,

i'm wondering if someone could help.....we are using SQL 2008 R2 and are wondering if anyone knows of any script/s that will generate one email which has a summary all database and transaction log backups completed and failed on all our SQL servers.

any help would be much appreciated..thanks.

SQL1999

unable to utilize full bandwidth for log shipping process on sql server 2008

$
0
0

There is a 64 Mbps private replication link over WAN between primary and secondary server hosting sql server 2008

Details : Intel(R) Xeon CPU E7-4830 @ 2.13 Ghz(2 processor) 64 bit,42 GB RAM hosted on Vmware on both primary and secondary site

there is a 64Mbps private tunnel MPLS link where data is compressed by riverbed hardware box (80-85 % compression is achieved for sql .trn files)

the problem is we are unable to use full bandwidth instead we are able to use only 3Mbps

Please guide me in right direction

thanks in advance


troubleshooting full tempdb

$
0
0

Today our applications started logging the following error for a brief period of time (maybe 1 minute total).

Message: The transaction log for database 'tempdb' is full.

Checked the drive that tempdb is on and it had plenty of space and by that time the error had stopped.   How do you troubleshooting this type of error postmortem to figure out what caused the issue in the first place?

sql 2008


Same query creating same number of rows but occasionally using a work table

$
0
0

Between different runs against the same server once a while we get a worktable usage (the spill to tempdb on the sort operator happens on every run and every run is under maxdop 1) and the duration of the query is a lot higher. I cannot justify what is causing the worktable usage.

What will cause a worktable usage in a query, is there a list of things what can cause it documented somewhere?

Tyank you


Gokhan Varol

Data warehouse

$
0
0

Just wanted to know how the sql serveroptimisation...We have 10 Tb of data in datawarehouse and client wants us to handle strategy for optimisation assuming the data to grow my 100% comparitively.Any Inputs on the above ?Any idea of how it can be done ? other than version upgrade.. Genaralise inputs can be helpful to build and research on...

Move a Database from SQL Server Express 2008 to SQL Server 2005 (SharePoint)

$
0
0

I have a need to move a SharePoint Content database from an instance od SQL Server express 2008 R2 to SQL Server 2005 (SP 4).

The SQL 2005 can run SharePoint, but I am having problems with the database (I am a SharePoint person, rather than a SQL Server person) as SQL 2008 databases cannot be attached directly in SQL 2005.

  • The process of Detaching and then Attaching does not work due to compatibility issues.
  • Using Export / Import, I can get the data into the 2005 instance, but there are lots of Stored procedures to get across.
  • Somebody suggested that I change the Copatibility setting in Properties to 90 (SQL 2005), but this did not make a difference
  • I tried using Redgate SQL Coompare, but ran into an error on one of the SPs, with the message talking about deadlocks

Can anybody help me?


SQL server Agent Job email notifications not being sent

$
0
0
I trying to set up some failure job Email notifications on Sql Server Agent jobs. 
So, I configured database mail and tested and was able to receive mail through sp_send_dbmail and "Test mail"
option under database mail.
 
I enabled the mail session on sql server Agent and selected DatabaseMail and <<ProfileName>> for Mail system and Mail Profile
options and restarted the sql server agent. But still I do not receive email notifications. 
also, the operators are configured fine and have correct email id assigned.

below is what I see in the agent error log after I restarting
Message

[355] The mail system failed to initialize; check configuration settings
[264] An attempt was made to send an email when no email session has been established

Do not know why it says no email session has been establised. SQL Server Version : Sql server 2005 standard edition SP3(x64).
Also, I restarted Sql server agent several times. so, I think that's not an issue.

again, I can receive mails when I do sp_send_dbmail but it is only issue sql server agent mail notifications.

Please advice.

Hope it Helps!!

SQL server 2008 R2 Log shipping Primary on Standard and Enterprise as standby

$
0
0

Hi,

Want to establish Log shipping between SQL server 2008 R2 Primary on Standard and standby server  on Enterprise as.

Is there any issue regarding saver version but different editions?

Regards

Sachin


Sachin Butala,System administrator

Program_name in sys.dm_exec_sessions

$
0
0

We are running the SQL Services with domain account and for auditing reasons we are collecting information as who connected ,When , from which program etc using log on triggers ... using sys.dm_exec_sessions.

But i am recently seeing a connection from the SQL Service account (domain\svc) with program name as "SendCryptoKeytoServer" couldn't find what this connection for (whether NTLM /kerboros authentication or something ??? ) if you have any idea why this program name shows as "SendCryptoKeytoServer"  and any links saying more about this connections from svc account ...please reply

running on :: SQL 2005 EE , SP4 ,Windows 2003 EE ,SP2


Madhava rao.M

database transaction log size grow too big

$
0
0

Hi,

i got a question regarding my transaction log files. it keeps on growing now the size is 170+GB. while the database size is not up to 1 GB. i try to truncate n shrink the log but the size still the same. i've try take full backup then log backup then truncate, also the size wont change. this is a production database. any idea how can i clear up the transaction log size. i use sql server 2008.

ex code use to shrink:-

USE #####
 GO
 DBCC SHRINKFILE(######_log, 1)

Thanks.


kneeah

SQL Server - Runing properly with Instalation Failures and Router?

$
0
0

Hello,
I've bought SQL Server 2012 but i have some complement problems involve.
First of all.. in the installation history i have two failures:
- Database Engine Services
- SQL Server Replication

Also i'm using router for wide internet connection.

My problem is when i try to connect to SQL Server and i pass the info correctly it still give me the following error:

"Cannot connect to ZDRAVEC-HP\RAYONLINE
Additional information:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server /Instance Specified) (Microsoft SQL Server)"

Question about proper index on table to minimize deadlocking

$
0
0

We have a deadlocking issue when two queries try to access the same table. (Sql 2005 Profiler shows us the deadlock. The INSERT statement is the "winner" and the SELECT against the same table the "victim"). The table involved has no indexes at all except for a primary key index. The INSERT use 5 table fields in its "WHERE\AND" clause. The SELECT statement uses the same 5 fields plus an additional 3 fields. If I want to create an index on that table to address this deadlocking would it include all 8 fields used by the SELECT statement or only the 5 used by the INSERT?

TIA,

edm2

DBCC FreeprocCache..Made the application up..need help

$
0
0

We are supporting a share point application with huge content Database. And the applicaiton went down...and it came back live after we ran dbcc freeproccache().

before running the freeproc cache we took the dbcc memory stats..and it looks like below...Can someone please elaborate me..whether heavy caching can bring down an application, and how to detect it and clear it..?

____________________________________________________________________________________________________________
Buffer Distribution            Buffers
------------------------------ -----------
Stolen                         18122
Free                           17872
Cached                         429165
Database (clean)               1230597
Database (dirty)               8122
I/O                            5
Latched                        53

(7 row(s) affected)

Buffer Counts                  Buffers
------------------------------ --------------------
Committed                      1703936
Target                         1703936
Hashed                         1238282
Stolen Potential               1168213
External Reservation           2318
Min Free                       512
Visible                        1703936
Available Paging File          6026665

(8 row(s) affected)

Procedure Cache                Value
------------------------------ -----------
TotalProcs                     2792
TotalPages                     418557
InUsePages                     7147

(3 row(s) affected)


Full Text Indexing Locks

$
0
0

SQL Server 2008 SP3

Does the population or rebuild or incremental updates on a FTI lock the source table at all? I am doubting it does but have to ask ....

The FTI is on a single table with an Identity column as the PK and we are populating the data from one column. Total rows is a few million.

Thanks!!


Consolidate databases in a single sql serve box - SQL Server 2008 R2 - collate problems ?

$
0
0

I have to migrate dbs from SQL Servers 2005 EE 64 bit to a single sql server box with SQL Server 2008 R2 SP1 EE 64 Bits (cluster).

The collates are:

- Latin1_General_BIN – 12 dbs

- Latin1_General_CI_AS -9 dbs

- SQL_Latin1_General_CP1_CI_AS -3 dbs

- SQL_Latin1_General_CP1_CI_AI – 43 dbs

Questions : - Which collate I should choose for the sql server box ?

- What are expected problems with remaining databases with different collates ?

- What workaround can be done ?

Question about DBCC TRACEON(1222,-1)

$
0
0

We are having deadlocking issues on a prod server. I was going run DBCC TRACE ON(1222,-1) on the server and then read this on MSDN:

"Use DBCC TRACEON (trace# [, ....n],-1) only while users or applications are not concurrently running statements on the system."

(http://msdn.microsoft.com/en-us/library/ms187329.aspx)

Huh? Our deadlocking issue is triggered by user action. Running it after hours won't be of use

Any comments on that one?

TIA,

edm2

P.S.  I also plan to use DBCC TRACEOFF (1222,-1) when done with the tracing.

System DSN to Windows Azure SQL Database

$
0
0

I am struggling with setting up linked server connection to Azure SQL. Connection works easy from SSIS and SSMS 2012.

In the system DSN setup I select SQL 11 library, enter server name, login, password and default database. The connection test fails.


Kalman Toth Database & OLAP Architect
Paperback / Kindle: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012

Nonsensical results using columnstore index

$
0
0

I'm looking for any ideas to the results I'm getting from columnstore indexes in SP1.  Both should be impossible, but having them happen pretty much blows that out of the water.  This is a completely isolated system.  No other connections or queries being run.

Machine 1:
Virtual Machine - VMWare
Windows Server 2012 Enterprise
SQL Server 2012 Developer SP1
2 processors
2GB RAM - SQL Server has 1.5 GB allocated

Machine 2:
32 bit Windows 7
SQL Server 2012 Developer SP1
4 logical processors - dual core with hyper threading
4GB RAM - SQL Server has 1.5GB allocated

Test Script:

IFNOTEXISTS(SELECT 1 FROMsys.tablesWHERESCHEMA_NAME(schema_id)='dbo' ANDname='Test')
BEGIN
    CREATE TABLEdbo.Test
   
(TestIDINTIDENTITY(1,1),
    StateProvinceID INTNOTNULL,
    OrderAmount    MONEY   NOTNULL,
    CONSTRAINT pk_TestPRIMARYKEY(TestID));
END
ELSE
BEGIN
    DROP TABLEdbo.Test

   CREATETABLE dbo.Test
   
(TestIDINTIDENTITY(1,1),
    StateProvinceID INTNOTNULL,
    OrderAmount    MONEY   NOTNULL,
    CONSTRAINT pk_TestPRIMARYKEY(TestID));

END;

WITH
Temp_CTE(RowNum)
AS
(
SELECTTOP 10000000 ROW_NUMBER()OVER (ORDERBY (SELECTNULL))
FROM
sys.all_columnsaCROSS JOINsys.all_columnsb
    CROSS JOINsys.all_columnsc)
INSERT
INTOdbo.Test
(
StateProvinceID,OrderAmount)
SELECT
NTILE(51) OVER (ORDERBYRowNum),(RowNum * 5.0)/ NTILE(51) OVER (ORDERBYRowNum)
FROM
Temp_CTE;

CREATE
NONCLUSTEREDCOLUMNSTORE INDEXics_Address
ON
dbo.Test
(
StateProvinceID);
GO

SELECT
COUNT(DISTINCTStateProvinceID)
FROM
dbo.Test;
--DROP TABLE dbo.Test;

Problem 1:
Msg 701,Level 17, State 128,Line 1
There
isinsufficientsystemmemoryin resourcepool'default'torun thisquery.

I've modified the default resource pool on the 32 bit machine to 100%, but the 64 bit machine was left at the default 25%.  The columnstore index builds just fine with these 10 million rows on machine 1 (64 bit virtual machine), but fails with this 701 error on machine 2 (32 bit Windows 7).  I'm building a columnstore index across 38 MB of data on an instance with 1.5GB of memory allocated.  SQL Server has the same amount of memory available on both machines, but it runs out of memory on the 32 bit machine.  That makes no sense.  The 32 bit machine does have 2 more logical processors available to it, but the SQL Server memory available is more than 40 times the size of the data needing to be built into a columnstore index.  Yes, I know that the memory required to build a columnstore index is a function of the number of columns and the MAXDOP.  Even when I cut the number of processors available to the 32 bit machine to 2 so that it matches the processor availability of the 64 bit machine, I still get the 701 error.  I can cut the memory available to SQL Server on the 64 bit machine by 75% and the columnstore index still successfully creates.  So, I'm at a complete loss here.

Problem 2:
When I cut the number of rows in the table from 10 million to 1 million, I can get the columnstore index to create.  BUT, the count(distinct StateProvinceID) does not produce a consistent query plan.  I purposely set this test up so that it sits right in the value proposition for columnstore indexes, so I should be getting maximum effect.  SQL Server should be using the columnstore index AND it should be running in batch mode.  Machine 2 (32 bit Windows 7) runs in batch mode.  Machine 1 (64 bit Windows Server) runs in row mode.  It is the same size data set (1 million rows in the table on both machines).  It is precisely the same data set, not a single value is different across any of the 1 million rows.  It has a very high duplication rate and the query is computing an aggregate.  I even scaled the data set on the 64 bit Windows Server machine to 500 million rows and still can't get it to run in batch mode.


Mike Hotek mhotek@mssqlserver.com

Viewing all 15264 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>