473,499 Members | 1,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Index Performance

I have the following table with indexes

CREATE TABLE dbo.Scratch (

ItemID int IDENTITY (1, 1) NOT NULL ,
Login varchar (12) NOT NULL ,
StartDate datetime NULL ,
PayDate datetime NULL ,
LastDisconnect datetime NULL

)

GO

CREATE INDEX idxPayDate ON dbo.Scratch(PayDate)

GO

CREATE INDEX idxStartDate ON dbo.Scratch(StartDate)

GO

The index distribution stats show a very poor average row hits (whatever
that means) for these two indexes

e.g for idxPaydate its 61160 (11.89% very poor )

and there are many nulls in the distribution steps.

Also I have many queries with conditions like (paydate is null and startdate
is not null etc) which means the index will not be used anyway (is this
correct?). My application is giving timeouts for such queries.

So my question is how can I make better indexes and make sure they are used?

thx

(i'm using SQL 6.5 )


Jul 20 '05 #1
2 5329
Hi,

As you said most of your searches are based on both PayDate and StartDate,
Why dont you create an index based on both fields
and see how effective it is. I have seen so many instances where indivual
indexes are not beoing used in SQL 6.5.
Try creating the below index and see whether it is useful. If it increases
the performance you can drop the old 2 indexes.
CREATE INDEX idx_new ON dbo.Scratch(PayDate,StartDate)

Thanks
Hari
MCDBA

"Mansoor Azam" <ma******@shoa.net> wrote in message
news:c6************@ID-31123.news.uni-berlin.de...
I have the following table with indexes

CREATE TABLE dbo.Scratch (

ItemID int IDENTITY (1, 1) NOT NULL ,
Login varchar (12) NOT NULL ,
StartDate datetime NULL ,
PayDate datetime NULL ,
LastDisconnect datetime NULL

)

GO

CREATE INDEX idxPayDate ON dbo.Scratch(PayDate)

GO

CREATE INDEX idxStartDate ON dbo.Scratch(StartDate)

GO

The index distribution stats show a very poor average row hits (whatever
that means) for these two indexes

e.g for idxPaydate its 61160 (11.89% very poor )

and there are many nulls in the distribution steps.

Also I have many queries with conditions like (paydate is null and startdate is not null etc) which means the index will not be used anyway (is this
correct?). My application is giving timeouts for such queries.

So my question is how can I make better indexes and make sure they are used?
thx

(i'm using SQL 6.5 )

Jul 20 '05 #2
What is true for SQL-Server 7.0 and above is especially true for 6.5:
make sure the table has a clustered index! Currently, your table doesn't
seem to have one.

Apart from advantages in general, the clustered index is very useful for
range queries that return a fair percentage of all rows (such as the
queries you describe). In that case, you would to create the clustered
index on the columns mentioned in the WHERE clause.

FYI: SQL-Server 6.5 does not support index intersection, which means
that only one (or zero) indexes will be used for each table in the
query. Therefore, a compound index (as suggested by Hari) might also
help.

Hope this helps,
Gert-Jan
Mansoor Azam wrote:

I have the following table with indexes

CREATE TABLE dbo.Scratch (

ItemID int IDENTITY (1, 1) NOT NULL ,
Login varchar (12) NOT NULL ,
StartDate datetime NULL ,
PayDate datetime NULL ,
LastDisconnect datetime NULL

)

GO

CREATE INDEX idxPayDate ON dbo.Scratch(PayDate)

GO

CREATE INDEX idxStartDate ON dbo.Scratch(StartDate)

GO

The index distribution stats show a very poor average row hits (whatever
that means) for these two indexes

e.g for idxPaydate its 61160 (11.89% very poor )

and there are many nulls in the distribution steps.

Also I have many queries with conditions like (paydate is null and startdate
is not null etc) which means the index will not be used anyway (is this
correct?). My application is giving timeouts for such queries.

So my question is how can I make better indexes and make sure they are used?

thx

(i'm using SQL 6.5 )


--
(Please reply only to the newsgroup)
Jul 20 '05 #3

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

Similar topics

5
10846
by: Kamil | last post by:
Hello What should I use for better perfomance since unique constraint always use index ? Thanks Kamil
1
3178
by: Gregory.Spencer | last post by:
Hi there, Using PHPMyAdmin and it is very usefully reporting problems with my MySQL DB. "PRIMARY and INDEX keys should not both be set for column `column_name`" and
1
3402
by: Johann Uhrmann | last post by:
Hello, are there any experiences about the performance of indices with different data types. How do the performance of an index that consists of - an integer field - a varchar() field - a...
8
4823
by: Andr? Queiroz | last post by:
Hi, I have a table with 10M records and col A has a index created on it. The data on that table has the same value for col A on all 10M records. After that I insert diferent values for that column...
9
3153
by: WalterR | last post by:
This is my first time here, so there may be earlier relevant threads of which I am unaware. Though my experience with DB2 is not extensive, such as it is was under OS/390 or equ. My main...
8
10269
by: Sam | last post by:
Hi, Here is my code : For Each row As DataRow In ds.Tables(0).Rows next How can I get the index of the row being processed ? Thx
12
3035
by: bernhard.willems | last post by:
We are using DB2 UDB version 8.1 fp7 & fp9 on AIX 5.2. On our databases we do massive inserts and deletes (millions of rows). The performance is dramatically reduced because of pseudo deleted keys....
0
1317
by: ep4169 | last post by:
I have to regularly import records into a table in the database that also contains records that were created internally. Those that are imported have an ImportRecordID column that I use to ensure...
6
3918
by: Henry J. | last post by:
I have a composite index on two columns in a table. However, the index is not used in a query that restricts the 2nd column to a constant. If both columns are linked with columns in other join...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6893
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...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
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...

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.