Showing posts with label therei. Show all posts
Showing posts with label therei. Show all posts

Monday, March 26, 2012

Performance question

Hello there
I have two tables i match with them. the field i match is none clustered
index.
When i make INNER JOIN between them it takes less then left or right join.
And inspite both of the fields have index the execution plan use hash join.
Whay it is like that?The reason for this is the way that the query processer works internally.
The Inner join will select rows which are in both of the two tables
mentioned in the join.
The left join will select all the rows from the left table, regardless of if
they exist in the right hand table.
If you look at the execution plans it's likely that you'll see an index s
for the inner join and an index scan for the left join.
Regards
Colin Dawson
www.cjdawson.com
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:uHNGAOrZGHA.1348@.TK2MSFTNGP05.phx.gbl...
> Hello there
> I have two tables i match with them. the field i match is none clustered
> index.
> When i make INNER JOIN between them it takes less then left or right join.
> And inspite both of the fields have index the execution plan use hash
> join.
> Whay it is like that?
>|||Roy Goldhammer (roy@.hotmail.com) writes:
> I have two tables i match with them. the field i match is none clustered
> index.
> When i make INNER JOIN between them it takes less then left or right
> join. And inspite both of the fields have index the execution plan use
> hash join.
> Whay it is like that?
Since neither tables, nor indexes, nor indication of table sizes were
included, I can only respond in general terms.
SQL Server has three differnt strategies to join tables: loop join, merge
join and hash join.
With a loop join, SQL Server finds rows in one table, and for each row
looks up a row in the other table.
With a merge join, SQL Server scans both tables in parallell. Merge join
presumes that the inputs are sorted on the same value.
With a hash join, SQL Server scans both tables and builds a hash table
that is then used for lookup.
Loop join is good when the other table is large, and only a handful row
will be hit. But if many rows are to be selected, the loop join is
expensive, and it's cheaper to scan once.
SQL Server does not know beforehand which will be the most expensive,
but the optimizer computes estimates from the statistics sampled about the
data.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Monday, March 12, 2012

performance problem

Hello there
I have table with at least 30,000,000 records
When i do simple select with 3 records who are indexed i get 90% on bookmark
lookup in the execution plan
what can cause it?have you got these indexes as non-cluster and besides of that, living in
another filegroup?
--
Please post DDL, DCL and DML statements as well as any error message in
order to understand better your request. It''s hard to provide information
without seeing the code. location: Alicante (ES)
"Roy Goldhammer" wrote:

> Hello there
> I have table with at least 30,000,000 records
> When i do simple select with 3 records who are indexed i get 90% on bookma
rk
> lookup in the execution plan
> what can cause it?
>
>|||> When i do simple select with 3 records who are indexed i get 90% on bookmarkd">
> lookup in the execution plan
When you say "records" I assume you mean "columns". A bookmark lookup may be
the best option for the optimizer if the index scans might take longer.
Are the statistics up to date? What's the query? Where are the indexes? What
kind of indexes are they?
ML
http://milambda.blogspot.com/|||Roy,
That seems right. And I guess the other 10% is caused by the index s.
All steps in the query plan will add up to 100%, even if the entire
query runs in a few millisecond. So the 90% is just the step cost in
relation to the total cost.
Is there anything you are worried about? The entire query probably takes
less than 20 logical reads and just a few milliseconds to run...
Gert-Jan
Roy Goldhammer wrote:
> Hello there
> I have table with at least 30,000,000 records
> When i do simple select with 3 records who are indexed i get 90% on bookma
rk
> lookup in the execution plan
> what can cause it?

performance problem

Hello there
I have table with more then 30,000,000 records.
When i do simple select on 3 fields who are indexes, i see on the execution
plan 90% on bookmark lookup.
What can cause this?"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:Oea7Jf9UGHA.4792@.TK2MSFTNGP14.phx.gbl...
> Hello there
> I have table with more then 30,000,000 records.
> When i do simple select on 3 fields who are indexes, i see on the
> execution plan 90% on bookmark lookup.
> What can cause this?
Date: Sat, 31 Dec 2005 10:56:24 +0200
Roy, fix your system clock please.
You're still celebrating New Years Eve.

Performance problem

Hello there
I have two tables with combination of two fields that aren't unique in both
tables.
To make them unique i must, create view of the last id of the fields.
example SELECT Fld1, Fld2, max(id)
FROM tbl
GROUP BY Fld1, Fld2
This cause serious performace problem.
Is there a way to handle it?1)How much of a performance problem?
2)can you send details of indexes implemented?
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:u8JN8LSYGHA.3604@.TK2MSFTNGP02.phx.gbl...
> Hello there
> I have two tables with combination of two fields that aren't unique in
both
> tables.
> To make them unique i must, create view of the last id of the fields.
> example SELECT Fld1, Fld2, max(id)
> FROM tbl
> GROUP BY Fld1, Fld2
> This cause serious performace problem.
> Is there a way to handle it?
>|||Whell Jack:
1. according to execution plan it caust at least 10 subtree cost more. and
on data which is more then 1,000,000 records any query can take more then an
hour.
2. fld1, and fld2 are indexes as non clustered.
What i need to do?
"Jack Vamvas" <delete_this_bit_jack@.ciquery.com_delete> wrote in message
news:Beydna5nIMCvcdzZnZ2dnUVZ8qWdnZ2d@.bt
.com...
> 1)How much of a performance problem?
> 2)can you send details of indexes implemented?
> --
> Jack Vamvas
> ___________________________________
> Receive free SQL tips - www.ciquery.com/sqlserver.htm
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:u8JN8LSYGHA.3604@.TK2MSFTNGP02.phx.gbl...
> both
>|||Hi Roy
Do you have an index on [ID] column?
I suggest you to create a COVERING index as
CREATE INDEX Covering_idx on TableName(Fld1, Fld2, id) which may very useful
particular along with ORDER BY clause
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:ug0QbaSYGHA.3328@.TK2MSFTNGP02.phx.gbl...
> Whell Jack:
> 1. according to execution plan it caust at least 10 subtree cost more. and
> on data which is more then 1,000,000 records any query can take more then
> an hour.
> 2. fld1, and fld2 are indexes as non clustered.
> What i need to do?
> "Jack Vamvas" <delete_this_bit_jack@.ciquery.com_delete> wrote in message
> news:Beydna5nIMCvcdzZnZ2dnUVZ8qWdnZ2d@.bt
.com...
>|||Roy Goldhammer (roy@.hotmail.com) writes:
> I have two tables with combination of two fields that aren't unique in
> both tables.
> To make them unique i must, create view of the last id of the fields.
> example SELECT Fld1, Fld2, max(id)
> FROM tbl
> GROUP BY Fld1, Fld2
> This cause serious performace problem.
> Is there a way to handle it?
Maybe there is, but with the tiny amount of information you have posted,
it is impossible to give any useful advice.
I suggest that you post:
1) CREATE TABLE statements for you tables.
2) CREATE INDEX statements for the tables.
3) CREATE VIEW statement for your view.
4) A sample query from the view.
5) An indication of the number of rows in the table.
Output from SET STATISTICS PROFILE ON is also good.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||That you need to do is redesign your tables to have a primary key. If
you can't alter this schema, then consider implementing a reporting
database that has a correct schema and design a process to move data
from the original source to your reporting warehouse.
Performance may be an issue, but if you're only moving data
periodically, that issue is mitigated. As others have posted, a
clearer definition would be helpful.
HTH,
Stu|||Yes Uri. The ID is the primary key clustered index.
I have also indexes on Fld1 and Fld2
Whay this is not enouth?
"Uri Dimant" <test@.test.com> wrote in message
news:Od9nH6SYGHA.4652@.TK2MSFTNGP04.phx.gbl...
> Hi Roy
> Do you have an index on [ID] column?
> I suggest you to create a COVERING index as
> CREATE INDEX Covering_idx on TableName(Fld1, Fld2, id) which may very
> useful particular along with ORDER BY clause
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:ug0QbaSYGHA.3328@.TK2MSFTNGP02.phx.gbl...
>

Performance Problem

Hello there
I have sql server database. In there i have two tables with indexes. When i
run simple select between these two tables i get hash join in the execution
plan.
The reason of the hash join is a result of selecting the wrong indexes on
the execution plan.
Whay it use the wrong index? and how can i force it to select the write
index?
any help would be usefulCan you give us the select query that you are using?|||WOudl be easier with an execution plan, ddl or the Select to encounter the
problem.
HTH, Jens Smeyer
http://www.sqlserver2005.de
--
"Roy Goldhammer" <roygoldh@.hotmail.com> schrieb im Newsbeitrag
news:e$9DEO%23QFHA.2356@.TK2MSFTNGP14.phx.gbl...
> Hello there
> I have sql server database. In there i have two tables with indexes. When
> i
> run simple select between these two tables i get hash join in the
> execution
> plan.
> The reason of the hash join is a result of selecting the wrong indexes on
> the execution plan.
> Whay it use the wrong index? and how can i force it to select the write
> index?
> any help would be useful
>
>