473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Table Index Construction

In a table design, properties window there is the Indexes/Keys tab.
I want to create a few indexes.

Row myID is the PK.
I also want indexes on rows myOne, myTwo, myThree.

In the selected index window: PK_tblName I see myID.
Do I put myOne, myTwo, myThree under that in the same index or do I
create three new indexes for the table?

Maybe this is DB Design 101 but it's not intuitive.

Any help is appreciated.
lq

Nov 13 '05 #1
3 1713
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11********************@f14g2000cwb.googlegrou ps.com:
In a table design, properties window there is the Indexes/Keys
tab. I want to create a few indexes.

Row myID is the PK.
I also want indexes on rows myOne, myTwo, myThree.

In the selected index window: PK_tblName I see myID.
Do I put myOne, myTwo, myThree under that in the same index or
do I create three new indexes for the table?

Maybe this is DB Design 101 but it's not intuitive.

Any help is appreciated.
lq

If you put myOne, myTwo and myThree under the same index name,
you have one index that sorts on the Primary Key, and the myOne
within the primary key, myTwo within myOne etc, and the whole
thing becomes the primary key. I doubt that this is what you
want.

Each index should be given a separate name, but may contain
multiple columns. So you could build indixes for myOne, myTwo,
and another index that sorts by myThree and myOne if it makes
sense to order that way.

Note that you don't need to create many manual indixes as Access
automatically indexes fields related in the relationships
window.
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #2
From:Microsoft® Jet Database Engine Programmer's Guide

**** begin quote ****
Use Indexes Cautiously
Although having indexes can reduce the time it takes to retrieve data,
they always carry a cost in maintenance and concurrency issues. When
should a field be indexed? There is no strict answer for this because
it depends on the type of application.

The first guideline is that fields containing highly duplicated data
should not be indexed (for example, fields with the Yes/No data type,
and fields that represent gender, state abbreviations, or country
codes).

The second guideline is that fields should not be indexed simply to
force Rushmore to use more than one index. An example of this would be
indexing a field called City and a field called PostalCode in a
customer table when the application is always going to be using both
fields for retrieval purposes. In this instance, the PostalCode field
is going to be the most unique index and would return a result set
faster if the City field was not indexed. Because Rushmore doesn't
need to use the index on the City field, omitting the index on the City
field will reduce overall disk I/O. Of course, if both values were not
always being entered and they were used alternatively and equally, then
having an index on both fields would probably be advantageous. Rushmore
is best utilized on combined indexes when they are required to generate
a unique result set.

It is also important to remember that indexes create concurrency
issues. One index page represents many data pages. Therefore, modifying
an index page can cause users with data on an entirely different data
page to be locked out when trying to update the indexed field.

To see this behavior, open the Northwind database in Microsoft Access
97 and turn on pessimistic locking by clicking Edited Record on the
Advanced tab of the Options dialog box (Tools menu). Update a value in
one indexed field in the Customers table, but don't move to the next
record. On another workstation, open the Customers table and try to
edit another value in the same indexed field that the other workstation
is editing. Next, try updating a value in a non-indexed field in the
Customers table. What will become evident is that substantially more
records of data are locked when you try to update a value in an indexed
field than when you try to update a value in a non-indexed field.
**** end quote ****

Nov 13 '05 #3
"lylefair" <ly******@yahoo.ca> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
From:Microsoft© Jet Database Engine Programmer's Guide

**** begin quote ****
[snip]
The first guideline is that fields containing highly duplicated
data should not be indexed (for example, fields with the Yes/No
data type, and fields that represent gender, state abbreviations,
or country codes).


I know this is the orthodoxy on this issue, but I don't follow it.

I've found in plenty of cases that sparsely-populated indexes (i.e.,
indexes with a small number of unique values) can massively speed up
selects that involve those fields. This includes Boolean fields, but
the most common case where I've encountered this is in one of the
fields I use for stamping records with data about who edited it. My
general approach is to have Created, Updated and UpdatedBy fields.
The first two are dates (with Default=Date()), and the last a text
field that I populate from CurrentUser() or from the Windows user
name (depends on the app). UpdatedBy never has a large number of
unique values as none of my apps are being used by more than a
couple dozen unique users.

So, by the orthodox rule, you'd not index such a field.

But when I *don't* index it, my routines to retrieve and sort and
count for the user stats take much, much longer. So, I put in the
indexes, despite the logic behind the orthodox rule not to index
such fields.

And I've seen the same thing on Boolean fields.

It does seem to me, though, that fields that have lots of Null
values are not speeded up nearly as much as those where all records
have a value.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4

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

Similar topics

10
by: John | last post by:
I have a table with two rows. On the first row is a text box and in the second row is an image. I have set the table cellpadding to 0 and cellspacing to 0. The table is leaving extra spaces in the...
6
by: Joe | last post by:
I have a: vector<string> which contains a few dozen elements. I want to find the index of the element containing a certain string. for example: vector<string> strings;...
16
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest week (when the db grow a lot). The DB is around...
9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
7
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
2
by: Bart Van der Donck | last post by:
Hello, I'm having difficulties to understand why the code below doesn't work. The idea is to generate an <iframe> with a higher z-index compared to an <object>. In Microsoft Internet Explorer 6,...
14
by: Gert Cuykens | last post by:
Is there a difference between <code> class HelloWorld: def index(self): index.exposed = True return "Hello world!" </code> and
4
by: Hemant Shah | last post by:
Folks, Our client has a program that browses whole table from begining to end. The table has 1 million rows in it. REORGCHK does not show any problems. It has unique index defined on KEY0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...

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.