473,394 Members | 1,748 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,394 software developers and data experts.

pros and cons of indexing

can anyone explain to me what the pros and cons are of creating indexes
on mysql tables. do they increase query speed? and if so at what cost?

im thinking of using them for a large table i have which contains two
text fields and may run into millions of records, is that advisable?

regards

marc

Aug 24 '06 #1
3 19643
In a word yes
see http://mysql.com/doc/refman/4.1/en/mysql-indexes.html
mc******@googlemail.com wrote:
can anyone explain to me what the pros and cons are of creating indexes
on mysql tables. do they increase query speed? and if so at what cost?

im thinking of using them for a large table i have which contains two
text fields and may run into millions of records, is that advisable?

regards

marc
Aug 24 '06 #2
mc******@googlemail.com wrote:
can anyone explain to me what the pros and cons are of creating indexes
on mysql tables. do they increase query speed? and if so at what cost?
If indexes are used, writing to table (for example inserting rows) is
slower, because in addition to just writing the data, MySQL needs to
handle the index file also. This is an issue usually only if you need
very fast inserts or you need to insert thousands of rows at the same
time and fast.

They might increase query speed or they might not. Basic rule is that if
you are searching some specific key in a table, using indexes in that
field will make query faster, but if you have index in some other field,
it won't make a difference.

For example if you have a table with 1000000 rows in it, and you want to
make this query:

select id,name from table_x where id=123123;

You will get a lot faster results if you have index in the id field.

On the other hand, if you don't have index in the id, but only in the
name field, the query will be as slow (or even few cpu ticks slower)
than it would be without indexes at all.
Aug 24 '06 #3
Aggro wrote:
mc******@googlemail.com wrote:
>can anyone explain to me what the pros and cons are of creating indexes
on mysql tables. do they increase query speed? and if so at what cost?

If indexes are used, writing to table (for example inserting rows) is
slower, because in addition to just writing the data, MySQL needs to
handle the index file also. This is an issue usually only if you need
very fast inserts or you need to insert thousands of rows at the same
time and fast.

They might increase query speed or they might not. Basic rule is that if
you are searching some specific key in a table, using indexes in that
field will make query faster, but if you have index in some other field,
it won't make a difference.

For example if you have a table with 1000000 rows in it, and you want to
make this query:

select id,name from table_x where id=123123;

You will get a lot faster results if you have index in the id field.

On the other hand, if you don't have index in the id, but only in the
name field, the query will be as slow (or even few cpu ticks slower)
than it would be without indexes at all.

to make things a bit faster as far as returning control is concerned,
you can also use query modifiers. these will help distribute server load
more effectively.

Aug 25 '06 #4

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

Similar topics

13
by: Axehelm | last post by:
Okay, I'm in a debate over whether or not static methods are a good idea in a general domain class. I'm personally not a fan of static methods but we seem to be using them to load an object. ...
1
by: Ronnie Patton | last post by:
Hello everyone can you help me find some information out about pros and cons using a global.asa in any asp application My co-works are saying its your choice to use one or not based on what the...
0
by: Sniffle | last post by:
Thanks... Say you have a double opt in mailing list, of which the subcriber list is store in the db. Im still somewhat of a newb, so bear with me... are there any pros/cons as to keeping the...
0
by: Steve | last post by:
We've recently got a new Server in. The server has 16Gb of RAM, 8 cpus etc We now have a choice of sticking with Windows 2000 Advanced Server or going with Windows 2003 Enterprise edition. ...
112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
2
by: Precious | last post by:
I have to give a presentation on pros and cons of .NET to our clients, who are already using our VB6/SQL Server 2000 application....(Yes, we are too late)...Many of you must have done the same...
5
by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
3
by: Andrea | last post by:
Hello everyone, I'd like to know which are the main pros and cons of using XML implementation in business organizations. >From a technical perspective, I find XML powerful, but looks like it is...
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: 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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.