Showing posts with label optimizing. Show all posts
Showing posts with label optimizing. Show all posts

Wednesday, March 28, 2012

Performance setting for a job

Hello,
I have a script that create some tables with (Select ... Into) for caching
and optimizing. This cache is created twice a w automatically. Problem:
The caching process needs 20 mins and while this 20 mins my website is not
working because SQL Server is busy with 100%.
Is there any chance to tell the SQL-Server that he should not use more than
20% of it's CPU for this job? No problem if it needs longer...
Thanks in advance.
CFIf you have indexes on the tables, drop these before you delete and
re-insert the data, then add the indexes after
It'll be quicker than inserting a huge amount of data into an indexed table.
You might want to consider using triggers or difference/update scripts to
maintain the tables over the course of the day if possible,
but without knowing what the cache tables consist of or how they are
populated it's difficult to say.
"Christian Funke" <ChristianFunke@.discussions.microsoft.com> wrote in
message news:1575B198-0132-46AA-8C32-1590110AA17A@.microsoft.com...
> Hello,
> I have a script that create some tables with (Select ... Into) for caching
> and optimizing. This cache is created twice a w automatically. Problem:
> The caching process needs 20 mins and while this 20 mins my website is not
> working because SQL Server is busy with 100%.
> Is there any chance to tell the SQL-Server that he should not use more
than
> 20% of it's CPU for this job? No problem if it needs longer...
> Thanks in advance.
> CF

Monday, March 12, 2012

Performance Optimizing

I am trying to monitor performancce of a database using PerfMon, but the
database instance does not show in PerfMon. I have noticed that some
databases show up in the list and some don't. These database are all active
and running. Why is this?Do you have more than 99 DBs on your SQL instance (including master,
model & tempdb)? SQL used to have a problem keeping perfmon stats for
dbids > 99. I don't know if Microsoft have fixed that issue with SQL
2005 or not. If that's what's happening with you then in perfmon you'll
see DBs whose dbid() <= 99 but not those DBs over that.
*mike hodgson*
http://sqlnerd.blogspot.com
Paul wrote:

>I am trying to monitor performancce of a database using PerfMon, but the
>database instance does not show in PerfMon. I have noticed that some
>databases show up in the list and some don't. These database are all active
>and running. Why is this?
>

Performance Optimizing

I am trying to monitor performancce of a database using PerfMon, but the
database instance does not show in PerfMon. I have noticed that some
databases show up in the list and some don't. These database are all active
and running. Why is this?This is a multi-part message in MIME format.
--060202050209050201010409
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Do you have more than 99 DBs on your SQL instance (including master,
model & tempdb)? SQL used to have a problem keeping perfmon stats for
dbids > 99. I don't know if Microsoft have fixed that issue with SQL
2005 or not. If that's what's happening with you then in perfmon you'll
see DBs whose dbid() <= 99 but not those DBs over that.
--
*mike hodgson*
http://sqlnerd.blogspot.com
Paul wrote:
>I am trying to monitor performancce of a database using PerfMon, but the
>database instance does not show in PerfMon. I have noticed that some
>databases show up in the list and some don't. These database are all active
>and running. Why is this?
>
--060202050209050201010409
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>Do you have more than 99 DBs on your SQL instance (including
master, model & tempdb)? SQL used to have a problem keeping
perfmon stats for dbids > 99. I don't know if Microsoft have fixed
that issue with SQL 2005 or not. If that's what's happening with you
then in perfmon you'll see DBs whose dbid() <= 99 but not those DBs
over that.</tt><br>
<div class="moz-signature">
<title></title>
<meta http-equiv="Content-Type" content="text/html; ">
<p><span lang="en-au"><font face="Tahoma" size="2">--<br>
</font></span> <b><span lang="en-au"><font face="Tahoma" size="2">mike
hodgson</font></span></b><span lang="en-au"><br>
<font face="Tahoma" size="2"><a href="http://links.10026.com/?link=http://sqlnerd.blogspot.com</a></font></span>">http://sqlnerd.blogspot.com">http://sqlnerd.blogspot.com</a></font></span>
</p>
</div>
<br>
<br>
Paul wrote:
<blockquote cite="midFDAEF3DA-76A8-4A36-920B-36D6E7DCFB0D@.microsoft.com"
type="cite">
<pre wrap="">I am trying to monitor performancce of a database using PerfMon, but the
database instance does not show in PerfMon. I have noticed that some
databases show up in the list and some don't. These database are all active
and running. Why is this?
</pre>
</blockquote>
</body>
</html>
--060202050209050201010409--

Performance Optimization

I have one problem while optimizing the sql query .For a few rows the
query works perfectly ,but as the number of rows increases it works but
gives wrong result.
I am using nested queries W/O aliasing . So what I assume is that Query
Optimizer is trying to flatten the query (converting it into joins) and
in the process ,because of no Alias Name takes a long time .
Something like this :--
Select * From EmpMst Where deptid in
( Select deptid from deptmst where deptname='acc')
--
into This --
--
Select * From EmpMst EM
Inner Join DeptMst DM On Dm.deptid = EM.deptid and DM.deptname='acc'
What might be the reasons for performance debacle? Following is what I
am using
1. Views (using *) --
2. Indexing (Clustered)
3. History Data (2 Billion Rows)
4. No Indexed views
5. Scalar Functions ( a bit For format Checking like All
alphabets,digits etc)
6. No Cursor
7. Updating a permanent temp table for intermediate results.
With Warm regards
Jatinder SinghIt is not clear to me what your question is? Is your question about
performance, or about getting a queries that always returns correct
results?
Which query are you currently using? The first or the second?
If you replace "*" with "EM.*" in the second query, then it is still not
(necessarily) equivalent to the first. If table DeptMst contains
duplicate deptid values, then the second query will return more rows
than the first. This effect can be cancelled out by adding the DISTINCT
keyword (and selection only from the EmpMst table).
Also, if column DeptMst.deptid contains NULLs, then the queries will
return different results.
If you are using SQL2K SP4, and the queries does not perform well, then
maybe you don't have proper indexes in place, or maybe your statistics
are not up to date. You did not post any DDL, so you indexing strategy
is unknown to us.
Gert-Jan
jsfromynr wrote:
> I have one problem while optimizing the sql query .For a few rows the
> query works perfectly ,but as the number of rows increases it works but
> gives wrong result.
> I am using nested queries W/O aliasing . So what I assume is that Query
> Optimizer is trying to flatten the query (converting it into joins) and
> in the process ,because of no Alias Name takes a long time .
> Something like this :--
> Select * From EmpMst Where deptid in
> ( Select deptid from deptmst where deptname='acc')
> --
> into This --
> --
> Select * From EmpMst EM
> Inner Join DeptMst DM On Dm.deptid = EM.deptid and DM.deptname='acc'
> What might be the reasons for performance debacle? Following is what I
> am using
> 1. Views (using *) --
> 2. Indexing (Clustered)
> 3. History Data (2 Billion Rows)
> 4. No Indexed views
> 5. Scalar Functions ( a bit For format Checking like All
> alphabets,digits etc)
> 6. No Cursor
> 7. Updating a permanent temp table for intermediate results.
> With Warm regards
> Jatinder Singh|||Hi There,
Sorry for not making myself clear . I know you can solve / suggest
some new points.
I am using First Query.
The example I had taken is where empid is PK in EmpMst and deptid is PK
in DeptMst so they cannot be null.
(if column DeptMst.deptid contains NULLs, then the queries will return
different results.
And If table DeptMst contains duplicate deptid values, then the second
query will return more rows than the first)
Select * From EmpMst Where deptid in
( Select deptid from deptmst where deptname='acc')
--
into This --
--
Select * From EmpMst EM
Inner Join DeptMst DM On Dm.deptid = EM.deptid and DM.deptname='acc'
That is the way I thought (I can be wrong) Query Optimizer will Convert
the queries with IN (Subquery...)
What might be the reasons for performance debacle (in Case I am using
Subqueries/Corelated Subqueries)?I assume here that Subqueries are
executed using tempdb.
Following is what I am using
1. Views (using *) --
2. Indexing (Clustered)
3. History Data (2 Billion Rows)
4. No Indexed views
5. Scalar Functions ( a bit For format Checking like All
alphabets,digits etc)
6. No Cursor
7. Updating a permanent temp table for intermediate results.
With Warm regards
Jatinder Singh|||You can look at the execution plan to see if the optimizer transforms
the query the way you describe. Press CTRL+G in Query Analyser and then
run the query to see the execution plan.
How the optimizer will execute your query depends on the relative table
sizes, the selectivity of the column you join on, and the 'width' of the
available indexes.
In this case the optimizer can choose between three strategies:
1a) use EmpMst as outer table and perform lookups for each relevant
deptid in DeptMst
1b) use DeptMst as outer table and perform lookups for each relevant
deptid in EmpMst (provided that you have an index on EmpMst(deptid))
(unlikely in your case)
2) scan both tables and join the result with the hashing algorithm
3) use a merge join to simulateneously scan both tables and join them
(unlikely in your case)
Under normal circumstances it is not necessary to manually rewrite the
query, because the optimizer will figure out the best plan.
However, if DeptMst and/or EmpMst are views, then no one can tell
anything about it, because you haven't posted any view definition, or
any DDL, indexes, etc. This is important information for performance
related questions. All 7 point you mention can affect performance, but
without addition information...
Maybe you can find some useful information on
http://www.sql-server-performance.com/
If not, then please provide more information (see
http://www.aspfaq.com/etiquette.asp?id=5006)
Gert-Jan
jsfromynr wrote:
> Hi There,
> Sorry for not making myself clear . I know you can solve / suggest
> some new points.
> I am using First Query.
> The example I had taken is where empid is PK in EmpMst and deptid is PK
> in DeptMst so they cannot be null.
> (if column DeptMst.deptid contains NULLs, then the queries will return
> different results.
> And If table DeptMst contains duplicate deptid values, then the second
> query will return more rows than the first)
> Select * From EmpMst Where deptid in
> ( Select deptid from deptmst where deptname='acc')
> --
> into This --
> --
> Select * From EmpMst EM
> Inner Join DeptMst DM On Dm.deptid = EM.deptid and DM.deptname='acc'
> That is the way I thought (I can be wrong) Query Optimizer will Convert
> the queries with IN (Subquery...)
> What might be the reasons for performance debacle (in Case I am using
> Subqueries/Corelated Subqueries)?I assume here that Subqueries are
> executed using tempdb.
> Following is what I am using
> 1. Views (using *) --
> 2. Indexing (Clustered)
> 3. History Data (2 Billion Rows)
> 4. No Indexed views
> 5. Scalar Functions ( a bit For format Checking like All
> alphabets,digits etc)
> 6. No Cursor
> 7. Updating a permanent temp table for intermediate results.
> With Warm regards
> Jatinder Singh|||Hi There,
Thanks for your input. The database design you are asking for is too
big to post . Your explaination is excellent. I should say with minimal
information ,you gave me geniune help. I hope someday , I will be
helping others as you do.
Yeah www.sql-server-performance.com is the site I regulary visit , not
to forget dbazine.com
I wish , I could learn how to flatten the correlated subqueries ; The
cursor based mindset push me there . Do you know some reference
articles / sites which can provide help on this topic ( Performance ).
Thanks Again.
With Warm regards
Jatinder Singh