SQL Server Express Casues CPU to Peg at 100% on Single Core Tablet - sql-server-express

I am running an instance of SQL Server Express on an old underpowered tablet PC used for a special purpose application. Periodically the SQL Server process kicks in and hammers the CPU at 100% bringing the application to a halt. (Technically, it doesn't halt, it just slows it down to the point where key processes time-out.) It will be another two or three years before the hardware is replaced so that's not an option. Is there a way to throttle SQL Server Express?

There are a few techniques to identify CPU-hogging activity on MSSQL, but since your box is completely unresponsive at the time, you have few options. Using SQL Profiler to run a background trace logging to a table or file might be your best bet.
Until very recently, you needed a paid version of MSSQL to use Profiler, however MS now includes Profiler with MSSQL Express 2012 SP1. Here's a direct download link:
http://www.microsoft.com/en-us/download/details.aspx?id=35579
(Note, you can probably install Profiler without upgrading your MSSQL server instance, if you don't want to).
If you've never used Profiler to diagnose CPU-hogging queries before, here's how I would suggest going about it:
new trace > connect to your MSSQL instace
make sure the "CPU" column is selected
make sure both the "started" and "completed" events for all the queries (Statement/Query/Batch/Procedure/etc) are checked.
Use a "column filter" to only show events where there is a value in the "CPU" column
Select a name for the trace, and a destination (table or .TRN file)
Start the trace and leave it running
After experiencing the CPU issue, once your box recovers: open the trace results, paying particular attention to the CPU column, and the date/time the 100% utilization started. Here's a link with more about using Profiler to analyze traces:
http://msdn.microsoft.com/en-us/library/ms175848.aspx

Related

SQL Server Profiler, Management Studio and Operations Studio hang after updating XML Data option

I've been using SSMS, SQL Server Profiler and SQL Operations Studio for a while now without issue. However, when some query text (TextData column) was getting truncated in the profiler, I decide to increase the SSMS "XML Data" size to "5 MB". Now all three applications hang at different spots.
SSMS and SOS hang when scripting table as a SELECT.
SQL Profiler hangs after moving past the connection dialog.
In event viewer, I see this error:
Application: ioc.exe
Framework Version: v4.0.30319
Description: The
process was terminated due to an unhandled exception. Exception Info:
System.AccessViolationException
It's also important to note, it is definitely not the case that the trace window/connection dialog/etc. is rendering off screen. Simply, the applications are hanging due to an unhandled exception.
Restoring Query Results options to default didn't work.
Relaunching SSMS/SQL Server Profiler/Sql Operations Studio didn't work.
Rebooting didn't work.
Running applications as Administrator didn't work.
I ended up pointing the connection dialog to another database to see if that made a difference and I was able to connect. This seems to have jarred something loose; I had to do this for all three applications separately, each time performing the task that hung on prior attempts on a different server fixed the problem. Though I wish I knew what was happening under the covers, I wasn't able to find any resources describing this same issue.
Once I pointed back to the original database I was able to launch each application successfully.
UPDATE - I later found that ioc.exe is Intel's Lenovo bloatware (Intel Online Connect). A security suite, which I promptly uninstalled.

Upgrading from EC2 M1.large instance to M4,2xlarge

I am looking to upgrade my current M1.large Windows SQL Standard instance to M4.2xlarge Window SQL Express.
I need to do this upgrade as I now have a higher performance requirement for the instance and also the SQL Express instance is way cheaper.
I am just wondering what would be the best approach for me to tackle this? The obvious issue here is the SQL database engine, as I am going from SQL standard to SQL express.
One of options is to create a new instance and manually rebuild the whole instance, but I want to keep the efforts minimum... I do have loads of data in the SQL database.
Any ideas?
SQL Express is a limited version of SQL server. Its limited to 1 GB of memory and 4 Cores. Upgrading your instances size but downgrading SQL server wont get you anymore performance.
You will need to stay with Standard if you expect to get the performance of the new instance. All you need to do is shut it down, change the size and start it back up again.

Limit resources available to query in SQL Server

I want to limit the system resources available to queries run by specific users in SQL Server 2008.
Some queries are seemingly running away with all the resources of the machine causing the server to become unresponsive.
My thought process is that if there is a way to cap the amount of resources (mem/cpu cycles/bw) a query can grab, this problem would go away.
Is this possible? Are there better techniques to accomplish this?
This is MS Sql Server 2008,
If you're running the Enterprise Edition, you could take a look at the Resource Governor.

Is there a way to track all the queries that has been executed by the server?

I want to be able to see all the queries that has been executed on the server last 2 days etc.
see the script, date of execution, sender etc.
is there any way?
I am using SQL X 2005.
I don't believe it's possible without SQL Server Profiler running.
Yes you can use SQL-Trace to log each command submitted to the server. It's the same mechanism used by the profiler, but you do not have to have the profiler or any other tool to use it.
There are two modes in which SQL Trace can run - in-memory buffer and disk file. The former is only used by profiler, is not documented and should not be used. Use the disk-file mode. The file can later on be opened on the same or different machine and even loaded into a table for analysis.
To learn more go to this page: http://msdn.microsoft.com/en-us/library/ms191511.aspx and search for section titled "To perform monitoring tasks with SQL Trace by using Transact-SQL stored procedures"
Here is a free, open-source Profiler tool that might help.
Profiler for Microsoft SQL Server 2005/2008 Express Edition

Logging ALL Queries on a SQL Server 2008 Express Database?

Is there a way to tell SQL Server 2008 Express to log every query (including each and every SELECT Query!) into a file?
It's a Development machine, so the negative side effects of logging Select-Queries are not an issue.
Before someone suggests using the SQL Profiler: This is not available in Express (does anyone know if it's available in the Web Edition?) and i'm looking for a way to log queries even when I am away.
SQL Server Profiler:
File → New Trace
The "General" Tab is displayed.
Here you can choose "Save to file:" so its logged to a file.
View the "Event Selection" Tab
Select the items you want to log.
TSQL → SQL:BatchStarting will get you sql selects
Stored Procedures → RPC:Completed will get you Stored Procedures.
More information from Microsoft: SQL Server 2008 Books Online - Using SQL Server Profiler
Update - SQL Express Edition:
A comment was made that MS SQL Server Profiler is not available for the express edition.
There does appear to be a free alternative: Profiler for Microsoft SQL Server 2005 Express Edition
There is one more way to get information about queries that has been executed on MS SQL Server Express described here.
Briefly, it runs smart query to system tables and gets info(text, time executed) about queries(or cached query plans if needed). Thus you can get info about executed queries without profiler in MSSQL 2008 Express edition.
SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC
…Late answer but I hope it would be useful to other readers here…
Using SQL Server Express with advanced auditing requirements such as this is not really optimal unless it’s only in development environment.
You can use traces (www.broes.nl/2011/10/profiling-on-sql-server-express/) to get the data you need but you’d have to parse these yourself.
There are third party tools that can do this but their cost will be quite high. Log explorer from ApexSQL can log everything but select and Idera’s compliance manager will log select statements as well but it’s cost is a lot higher.
You can log changes. SQL Server 2008 will make this especially easy with Change Data Capture. But SQL Server isn't very good at logging SELECTs.
It is theoretically possible with the profiler, but it will kill your performance. You might "get away with it" on your desktop, but I think you'll notice your machine acting slow enough to cause problems. And it definitely won't work after any kind of deployment.
One important point a couple others have missed already: unless they changed something for 2008 I didn't hear about, you can't trigger a SELECT.
Just for the record, I'm including the hints to use DataWizard's SQL Performance Profiler as a separate answer since it's really the opposite to the answer pointing at SQL Server Profiler.
There is a free trial for 14 days, but even if you need to buy it, it's only $20 for 3 servers (at the moment of writing, 2012-06-28). This seems more than fair to me considering the thousands everybody using SQL Server Express edition has saved.
I've only used the trial so far and it offers exactly what the OP was looking for: a way to trace all queries coming in to a specific database. It also offers to export a trace to an XML file. The paid version offers some more features but I haven't tried them yet.
Disclaimer: I'm just another developer messing with DBs from time to time and I'm in no way affiliated with DataWizard. I just so happened to like their tool and wanted to let people know it existed as it's helped me out with profiling my SQL Server Express installation.
I would either use triggers or use a third party software such as Red Gate to check out your SQL log files.
Seems that you can create traces using T-SQL
http://support.microsoft.com/kb/283790/
That might help.
The SQL query below can show simple query logs:
SELECT last_execution_time, text
FROM sys.dm_exec_query_stats stats
CROSS APPLY sys.dm_exec_sql_text(stats.sql_handle)
ORDER BY last_execution_time
This is how it looks like below: