473,915 Members | 5,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql 2005 - optimization - cannot use index

I have a very very strange situation with a particular application and sql
server 2005 enterprise.

This application combines numerical data from multiple tables. User can make
query over this kind of tables, can build queries with "group by" "order by"
and "join", "sum, count(*) ecc. on many many columns.

I cannot know the query that application is going to build, so I do not know
how to create indexes.
I cant make indexes on all the columns of course, so I'm creating some index
over columns that should be statistically used in the join, but when there
is a group by on a column chosen from the user, I realize that the plan
become non efficient with the famigerate "TABLE SCAN".

Can somebody, give me an idea, to optimize this situation.

Thanx

Massimo
Jan 26 '07 #1
4 2833
Massimo (ma*****@hotmai l.it) writes:
I have a very very strange situation with a particular application and sql
server 2005 enterprise.

This application combines numerical data from multiple tables. User can
make query over this kind of tables, can build queries with "group by"
"order by" and "join", "sum, count(*) ecc. on many many columns.

I cannot know the query that application is going to build, so I do not
know how to create indexes.
I cant make indexes on all the columns of course, so I'm creating some
index over columns that should be statistically used in the join, but
when there is a group by on a column chosen from the user, I realize
that the plan become non efficient with the famigerate "TABLE SCAN".

Can somebody, give me an idea, to optimize this situation.
My gut reaction is that I would want more information about how
the users will use the system. Will all combinations be equally common?
Are some important than others? Are some combinations so completely
meaningless, that the users should even be prevented from trying them
(as doing that could cause performance issues).

Maybe you should pre-aggregate data. But that leads to the thought that
this is something which should be in Analysis Services instead. (I have
no experience of Analysis Services, so I cannot say much more.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jan 26 '07 #2
Thanx for your answer, it's a very particular application, it wants to
explode some result from money activities.
It is used by banks. I cannot say more.
I'm an oracle dba (ocp), and I would use Partitioning as I do sometimes in
oracle, on the column in join in this case, to try to increase at least some
kind of parallelism, but the Database Tuning Advisor, with a trace of a day
of activity never suggests me, this kind of approach. So I think it is not a
good way.

So the only way, I'm thinking to follow is to speed up "table scan", but how
?

Oracle with the same database, the same data and the same indexes, is more
flexible and often succeed in using indexing, without any kind of HINTS in
the queries.

The sql 2005 engine doesnt understand, the way to use an index even if it
has a subset of the columns he needs, as oracle does.

With a particular query the DTA suggests to index all the columns in the
WHERE + all the columns in the GROUP BY + all the columns in the ORDER BY +
use the INCLUDE clause with the columns in the SELECT statement with
functions like SUM, ecc.

Massimo


"Erland Sommarskog" <es****@sommars kog.seha scritto nel messaggio
news:Xn******** **************@ 127.0.0.1...
Massimo (ma*****@hotmai l.it) writes:
I have a very very strange situation with a particular application and
sql
server 2005 enterprise.

This application combines numerical data from multiple tables. User can
make query over this kind of tables, can build queries with "group by"
"order by" and "join", "sum, count(*) ecc. on many many columns.

I cannot know the query that application is going to build, so I do not
know how to create indexes.
I cant make indexes on all the columns of course, so I'm creating some
index over columns that should be statistically used in the join, but
when there is a group by on a column chosen from the user, I realize
that the plan become non efficient with the famigerate "TABLE SCAN".

Can somebody, give me an idea, to optimize this situation.

My gut reaction is that I would want more information about how
the users will use the system. Will all combinations be equally common?
Are some important than others? Are some combinations so completely
meaningless, that the users should even be prevented from trying them
(as doing that could cause performance issues).

Maybe you should pre-aggregate data. But that leads to the thought that
this is something which should be in Analysis Services instead. (I have
no experience of Analysis Services, so I cannot say much more.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Jan 26 '07 #3
Massimo (ma*****@hotmai l.it) writes:
Thanx for your answer, it's a very particular application, it wants to
explode some result from money activities.
Data mining? In such case, Analysis Services is definitely your guy.
Oracle with the same database, the same data and the same indexes, is more
flexible and often succeed in using indexing, without any kind of HINTS in
the queries.

The sql 2005 engine doesnt understand, the way to use an index even if it
has a subset of the columns he needs, as oracle does.
The bitter truth is that if you try to implement an Oracle solution on
SQL Server, it is not going to turn out well. Just like an SQL Server
solution on Oracle would be bad.
With a particular query the DTA suggests to index all the columns in the
WHERE + all the columns in the GROUP BY + all the columns in the ORDER
BY + use the INCLUDE clause with the columns in the SELECT statement
with functions like SUM, ecc.
Yes, that gives you a covering index. This means that when the optimizer
has to scans the data, it only has to scan the relevant columns. This
means fewer pages to read, which means better performance. But if the
index is constrained to the WHERE clause only, locating the rows will
be faster. However, if the WHERE clause qualifies many rows, the
bookmark lookup for each row will be so expensive that a table scan
is better.

Unfortunately, with the tiny inforamtion I have about your system, it's
difficult to give very detailed advice.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jan 27 '07 #4
Thank you very much Erland,
it's difficult to give more informations, and I cannot detail it more.

You are right about oracle and sql server porting;
application should be tuned and live with the same RDBMS.

So definitively I'm suggesting to optimize what is possible:

-use best index (statistically)
-defrag indexes
-use dta on a typical workload (workload written on a trace with profiler
with "tuning" template for some days)
-evaluate partitioning on the column in join on the most accessed table

Bye
Massimo


"Erland Sommarskog" <es****@sommars kog.seha scritto nel messaggio
news:Xn******** **************@ 127.0.0.1...
Massimo (ma*****@hotmai l.it) writes:
Thanx for your answer, it's a very particular application, it wants to
explode some result from money activities.

Data mining? In such case, Analysis Services is definitely your guy.
Oracle with the same database, the same data and the same indexes, is
more
flexible and often succeed in using indexing, without any kind of HINTS
in
the queries.

The sql 2005 engine doesnt understand, the way to use an index even if
it
has a subset of the columns he needs, as oracle does.

The bitter truth is that if you try to implement an Oracle solution on
SQL Server, it is not going to turn out well. Just like an SQL Server
solution on Oracle would be bad.
With a particular query the DTA suggests to index all the columns in the
WHERE + all the columns in the GROUP BY + all the columns in the ORDER
BY + use the INCLUDE clause with the columns in the SELECT statement
with functions like SUM, ecc.

Yes, that gives you a covering index. This means that when the optimizer
has to scans the data, it only has to scan the relevant columns. This
means fewer pages to read, which means better performance. But if the
index is constrained to the WHERE clause only, locating the rows will
be faster. However, if the WHERE clause qualifies many rows, the
bookmark lookup for each row will be so expensive that a table scan
is better.

Unfortunately, with the tiny inforamtion I have about your system, it's
difficult to give very detailed advice.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Jan 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
961
by: Andrew Carlson | last post by:
system.BadImageFormatException: Field token out of range. Hello, I am trying to use the new Beta 2. I am not sure if this is even the place to ask. After installing, I was anxious to play with some of the new features. However, after creating a new project, I have a blank form, when I try to drag/drop a control to it I get the above error. Also, every two minutes or so, a dialog box occurs that says, "Field token out of range." Any...
7
3236
by: pankaj_wolfhunter | last post by:
Greetings, While loading data into Sql Server using BCP utility, we have to explicitly need to drop the indexes. then after loading the data we recreate them. I just want to know if this is possible through some other ways. i mean in DB2 we have an option of index rebuild option which takes care of this job. Do we have anything as such in BCP or is there some other way? Any help will be appreciated
3
9748
by: R.A.M. | last post by:
Hello, Could you explain me please the following error: "Database 'DemoDotNET' cannot be opened due to inaccessible files or insufficient memory or disk space. (Microsoft SQL Server, Error: 945)" I have checked: free disk space is large enough, I have much enough memory, other files in the directory are accessible. Here is tail of ERRORLOG:
3
1004
by: jamil | last post by:
I have developed an EXE that executes successfully when it exists and is launched from a Win2000 or XP client PC. If I was to copy this EXE to a network share, where the client has full admin access, the EXE fails to launch with an error. It displays something along the lines of the application has encountered a problem and needs to close. I am unable to debug it at all even though there is an option to debug when I receive this error....
5
1344
by: cmrhema | last post by:
Hello Help please I am working on vb.net 2005 I wrote the coding as below I have developed a console application When i run the program i get an error stating smtpexception was unhandled failure sending mail
0
1378
by: Piero 'Giops' Giorgi | last post by:
Hi! I'm using the Thesaurus search on a SQL Server 2005 Db The thesaurus file is built like this (Reduced version) <XML ID="Microsoft Search Thesaurus"> <thesaurus xmlns="x-schema:tsSchema.xml"> <diacritics = false/> <expansion>
4
1887
by: Artie | last post by:
A few months ago a customer moved from SQL 2000 to SQL 2005. The db was backed up on SQL 2000 and restored to SQL 2005. The application using this data works on SQL 2005 but takes no advantage of new features. The db on SQL 2000 was about 2.9GB, now on SQL 2005, it is 16.5GB. The db is set to Simple recovery so trx log is only 2mb. The mdf file is 16.5GB, Management Studio shows only 5mb free space. There has not been a huge increase...
9
7820
by: dpatel75 | last post by:
I am trying to copy a database from a SQL 2000 SP3 Windows 2000 server to a 2005 SP2 Windows 2003 server. I am trying to use detach and attach method (have tried both within Management Studio and T-SQL) and experience an error when attaching to the 2005 server: "CREATE FILE encountered operating system error 5 (error not found) while attempting to open or create the physical file 'xxxxxxxxxxxx' (Microsoft SQL Server, Error: 5123)" I have...
1
1470
by: newphpcoder | last post by:
Good day! I am newly in SQL Server 2005 and now I encountered error when i try to login. This is some of the information: Microsoft SQL Server 2005 Express Edition Server Type: Database Engine Servername:Servername\MSFW Authentication:SQL Server Authentication Login: sa Password:xxxx
0
9883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.