Showing posts with label cpu. Show all posts
Showing posts with label cpu. Show all posts

Friday, March 30, 2012

how to free memory used by prior query statement within a batch by TSQL?

Just Like these:

-- batch start
Select * from someTable --maybe a query which need much res(I/O,cpu,memory)

/*
can I do something here to free res used by prior statement?
*/

select * from someOtherTable
--batch end

The Sqls above are written in a procedure to automating test for some select querys.What about this:

select ...
DBCC DROPCLEANBUFFERS
select ...|||Won't that force a recompile of everything?

Gotta look that up...

btw...SQL Server will grab as much memory is available, and will only release it if it's not using it and something else needs it...

It's not very sociable...|||thanks for help, but it seemed not work as I hoped.

Sqlserver used 20M memory before I run the select query;
Sqlserver used 123M memory after I run the select query;
Sqlserver still used 123M memory after I run 'DBCC DROPCLEANBUFFERS', but I want memory used by Sqlserver not larger than 20M;

I don't know exactly how memory useage affect the performance of next query's execution, so I write down my primal Intention:

select... -- query A

/* do something here to make query B to be executed just as query A was not executed before( or minish query A's affection). */

select... -- query B

could I make it?|||here is my test plan:

there are query ABC..., and insert all querys into a table called querytbl;
open a cursor for all records from querytbl;
fetch next query from cursor;
while @.@.fetchstatus = 0
begin
exec query for 3 times and calculate average time spending;
fetch next query from cursor;
end
...

Is there any better test plan?(just test time spending)

Monday, March 19, 2012

How to find Queries which makes CPU 100% ?

Hi,
There is an application which makes connection of more than 300 users
to a SQL Server 2000 DB.
Most of the times the server CPU hits the 100% for 2-3 seconds.
Since lots of queries are fired hence i'm unable to track down which
query makes the CPU 100%.
I'm using the SQL profiler (with settings on the Duration filter),
still i'm unabl;e to track down the BAD Queries.
Please suggest me a way/method/application to TRACK DOWN THE QUERIES
RESPONSIBLE TO OVERLOAD THE CPU BY 100 %.
Thanks,
~Nimit Sharma.Hi
Turn on SQL Server Profiler and filter by CPU
<nimitsharma16@.gmail.com> wrote in message
news:1189330367.686296.120070@.19g2000hsx.googlegroups.com...
> Hi,
> There is an application which makes connection of more than 300 users
> to a SQL Server 2000 DB.
> Most of the times the server CPU hits the 100% for 2-3 seconds.
> Since lots of queries are fired hence i'm unable to track down which
> query makes the CPU 100%.
> I'm using the SQL profiler (with settings on the Duration filter),
> still i'm unabl;e to track down the BAD Queries.
> Please suggest me a way/method/application to TRACK DOWN THE QUERIES
> RESPONSIBLE TO OVERLOAD THE CPU BY 100 %.
> Thanks,
> ~Nimit Sharma.
>|||Generally, it a normal behavior when some query utilizie 100% of CPU for 2-3
seconds, specially if it is using the data that are already in cache. Do you
really need to track such queries?
"nimitsharma16@.gmail.com" wrote:
> Hi,
> There is an application which makes connection of more than 300 users
> to a SQL Server 2000 DB.
> Most of the times the server CPU hits the 100% for 2-3 seconds.
> Since lots of queries are fired hence i'm unable to track down which
> query makes the CPU 100%.
> I'm using the SQL profiler (with settings on the Duration filter),
> still i'm unabl;e to track down the BAD Queries.
> Please suggest me a way/method/application to TRACK DOWN THE QUERIES
> RESPONSIBLE TO OVERLOAD THE CPU BY 100 %.
> Thanks,
> ~Nimit Sharma.
>

Friday, March 9, 2012

How to find out CPU utilization for individual sql processes?

Sometimes is my CPU utilization is about 90-100%. SQL server cause this high
utilization.
Is it possible to find out which process (task or query) in SQL server is
responsible for thist CPU utilization?
Alesmy SQL server is 2000
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> Sometimes is my CPU utilization is about 90-100%. SQL server cause this
high
> utilization.
> Is it possible to find out which process (task or query) in SQL server is
> responsible for thist CPU utilization?
> Ales
>|||Hi,
You can get the CPU time not CPU usage. But using below query you can get
the SQL process using high cpu time.
select spid,cpu from sysprocesses order by cpu desc
--
Thanks
Hari
MCDBA
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:#tHRj#nWEHA.3528@.TK2MSFTNGP10.phx.gbl...
> my SQL server is 2000
> "Ales Baranek" <baranek@.extranet.cz> wrote in message
> news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> > Sometimes is my CPU utilization is about 90-100%. SQL server cause this
> high
> > utilization.
> > Is it possible to find out which process (task or query) in SQL server
is
> > responsible for thist CPU utilization?
> >
> > Ales
> >
> >
>|||You could run sp_who2 quickly twice, and look at the CPUTime column to see
which connection has the biggest increase. From there, you can then
retrieve the query either using DBCC INPUTBUFFER (pre-sp3) or the
::fn_get_sql function (sp3).
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Try MiniSQLBackup
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> Sometimes is my CPU utilization is about 90-100%. SQL server cause this
high
> utilization.
> Is it possible to find out which process (task or query) in SQL server is
> responsible for thist CPU utilization?
> Ales
>

How to find out CPU utilization for individual sql processes?

Sometimes is my CPU utilization is about 90-100%. SQL server cause this high
utilization.
Is it possible to find out which process (task or query) in SQL server is
responsible for thist CPU utilization?
Ales
my SQL server is 2000
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> Sometimes is my CPU utilization is about 90-100%. SQL server cause this
high
> utilization.
> Is it possible to find out which process (task or query) in SQL server is
> responsible for thist CPU utilization?
> Ales
>
|||Hi,
You can get the CPU time not CPU usage. But using below query you can get
the SQL process using high cpu time.
select spid,cpu from sysprocesses order by cpu desc
Thanks
Hari
MCDBA
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:#tHRj#nWEHA.3528@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> my SQL server is 2000
> "Ales Baranek" <baranek@.extranet.cz> wrote in message
> news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> high
is
>
|||You could run sp_who2 quickly twice, and look at the CPUTime column to see
which connection has the biggest increase. From there, you can then
retrieve the query either using DBCC INPUTBUFFER (pre-sp3) or the
::fn_get_sql function (sp3).
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Try MiniSQLBackup
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> Sometimes is my CPU utilization is about 90-100%. SQL server cause this
high
> utilization.
> Is it possible to find out which process (task or query) in SQL server is
> responsible for thist CPU utilization?
> Ales
>

How to find out CPU utilization for individual sql processes?

Sometimes is my CPU utilization is about 90-100%. SQL server cause this high
utilization.
Is it possible to find out which process (task or query) in SQL server is
responsible for thist CPU utilization?
Alesmy SQL server is 2000
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> Sometimes is my CPU utilization is about 90-100%. SQL server cause this
high
> utilization.
> Is it possible to find out which process (task or query) in SQL server is
> responsible for thist CPU utilization?
> Ales
>|||Hi,
You can get the CPU time not CPU usage. But using below query you can get
the SQL process using high cpu time.
select spid,cpu from sysprocesses order by cpu desc
Thanks
Hari
MCDBA
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:#tHRj#nWEHA.3528@.TK2MSFTNGP10.phx.gbl...
> my SQL server is 2000
> "Ales Baranek" <baranek@.extranet.cz> wrote in message
> news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> high
is[vbcol=seagreen]
>|||You could run sp_who2 quickly twice, and look at the CPUTime column to see
which connection has the biggest increase. From there, you can then
retrieve the query either using DBCC INPUTBUFFER (pre-sp3) or the
::fn_get_sql function (sp3).
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Try MiniSQLBackup
"Ales Baranek" <baranek@.extranet.cz> wrote in message
news:ev4dEsnWEHA.384@.TK2MSFTNGP10.phx.gbl...
> Sometimes is my CPU utilization is about 90-100%. SQL server cause this
high
> utilization.
> Is it possible to find out which process (task or query) in SQL server is
> responsible for thist CPU utilization?
> Ales
>

How to find out CPU saturation in T-SQL

Hello,
I was wondering if there is a way to find out in T-SQL how busy CPU is. I
would like to get the same information as shown in CPU usage graph in Task
Manager.
Thanks,
IgorThere are other processes other than SQL Server that consume CPU resources.
Perhaps you can get this information using WMI.
"Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
news:elq%23aIoKFHA.3960@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I was wondering if there is a way to find out in T-SQL how busy CPU is. I
> would like to get the same information as shown in CPU usage graph in Task
> Manager.
> Thanks,
> Igor
>|||I was hoping to obtain this information using T-SQL.
<WKidd> wrote in message news:%23ImbyToKFHA.1284@.TK2MSFTNGP14.phx.gbl...
> There are other processes other than SQL Server that consume CPU
> resources. Perhaps you can get this information using WMI.
> "Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
> news:elq%23aIoKFHA.3960@.TK2MSFTNGP09.phx.gbl...
>|||Igor Marchenko wrote:
> Hello,
> I was wondering if there is a way to find out in T-SQL how busy CPU
> is. I would like to get the same information as shown in CPU usage
> graph in Task Manager.
> Thanks,
> Igor
Not for the entire server. Only for SQL Server.
David Gugick
Imceda Software
www.imceda.com|||Could you please tell me how to do it for SQL server? I would like to know
how much of CPU percent wise is used by SQL server. Similar to what is shown
in process tab of Task bar.
Thanks,
Igor
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OJfqq4pKFHA.3552@.TK2MSFTNGP12.phx.gbl...
> Igor Marchenko wrote:
> Not for the entire server. Only for SQL Server.
> --
> David Gugick
> Imceda Software
> www.imceda.com|||You can use perfmon to see how much cpu SQL server is using, and it auto
refreshes so you watch and record performance.
Under "Process" performance object, select "% Processor Time", and in the
"Select instance from a list" section, select "sqlservr".
Obviously this is not a t-sql solution, but probably more intuitive,
especially if you want to log the results to review later.
Simon Worth
"Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
news:uvuFOvxKFHA.440@.TK2MSFTNGP10.phx.gbl...
> Could you please tell me how to do it for SQL server? I would like to know
> how much of CPU percent wise is used by SQL server. Similar to what is
shown
> in process tab of Task bar.
> Thanks,
> Igor
> "David Gugick" <davidg-nospam@.imceda.com> wrote in message
> news:OJfqq4pKFHA.3552@.TK2MSFTNGP12.phx.gbl...
>|||Igor Marchenko wrote:
> Could you please tell me how to do it for SQL server? I would like to
> know how much of CPU percent wise is used by SQL server. Similar to
> what is shown in process tab of Task bar.
> Thanks,
> Igor
From T-SQL, you can use the @.@.CPU_BUSY global variable along with
@.@.TIMETICKS. You'll have to search Google for the required calculation
as you'll have to compare the toal cpu used over an interval as compared
to the total time.
David Gugick
Imceda Software
www.imceda.com

How to find out CPU saturation in SQL server

Hello,
I was wondering if there is a way to find out in T-SQL how busy CPU is. I
would like to get the same information as shown in CPU usage graph in Task
Manager.
Thanks,
Igor
Performance Monitor ?
Gopi
"Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
news:%23d21PIoKFHA.2936@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I was wondering if there is a way to find out in T-SQL how busy CPU is. I
> would like to get the same information as shown in CPU usage graph in Task
> Manager.
> Thanks,
> Igor
>
|||I would like to ontain this information programmatically ideally using
T-SQL.
Thanks,
Igor
"rgn" <gopinathr@.healthasyst.com> wrote in message
news:%23y8EvkvKFHA.3960@.TK2MSFTNGP09.phx.gbl...
> Performance Monitor ?
> Gopi
> "Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
> news:%23d21PIoKFHA.2936@.TK2MSFTNGP15.phx.gbl...
>

How to find out CPU saturation in SQL server

Hello,
I was wondering if there is a way to find out in T-SQL how busy CPU is. I
would like to get the same information as shown in CPU usage graph in Task
Manager.
Thanks,
IgorPerformance Monitor ?
Gopi
"Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
news:%23d21PIoKFHA.2936@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I was wondering if there is a way to find out in T-SQL how busy CPU is. I
> would like to get the same information as shown in CPU usage graph in Task
> Manager.
> Thanks,
> Igor
>|||I would like to ontain this information programmatically ideally using
T-SQL.
Thanks,
Igor
"rgn" <gopinathr@.healthasyst.com> wrote in message
news:%23y8EvkvKFHA.3960@.TK2MSFTNGP09.phx.gbl...
> Performance Monitor ?
> Gopi
> "Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
> news:%23d21PIoKFHA.2936@.TK2MSFTNGP15.phx.gbl...
>

How to find out CPU saturation in SQL server

Hello,
I was wondering if there is a way to find out in T-SQL how busy CPU is. I
would like to get the same information as shown in CPU usage graph in Task
Manager.
Thanks,
IgorPerformance Monitor ?
Gopi
"Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
news:%23d21PIoKFHA.2936@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I was wondering if there is a way to find out in T-SQL how busy CPU is. I
> would like to get the same information as shown in CPU usage graph in Task
> Manager.
> Thanks,
> Igor
>|||I would like to ontain this information programmatically ideally using
T-SQL.
Thanks,
Igor
"rgn" <gopinathr@.healthasyst.com> wrote in message
news:%23y8EvkvKFHA.3960@.TK2MSFTNGP09.phx.gbl...
> Performance Monitor ?
> Gopi
> "Igor Marchenko" <igormarchenko@.hotmail.com> wrote in message
> news:%23d21PIoKFHA.2936@.TK2MSFTNGP15.phx.gbl...
>> Hello,
>> I was wondering if there is a way to find out in T-SQL how busy CPU is. I
>> would like to get the same information as shown in CPU usage graph in
>> Task Manager.
>> Thanks,
>> Igor
>