Re: MySQL Indexes

2011-10-07 Thread mos
At 01:58 PM 10/7/2011, you wrote: Do you have any good documentation with regards creating indexes. Also information for explain statement and what would be the desired result of the explain statement? This might help: http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html http://www.site

Re: MySQL Indexes

2011-10-07 Thread Michael Dykman
The second index you specified '(field_b, field_a)' would be usable when querying on field_b alone, or both fields in conjunction. This particular index is of no value should you be querying 'field_a' alone. Then that first index '(field_a, field_b)' would apply. - md On Fri, Oct 7, 2011 at 2:

Re: MySQL Indexes

2011-10-07 Thread Neil Tompkins
Do you have any good documentation with regards creating indexes. Also information for explain statement and what would be the desired result of the explain statement? On 7 Oct 2011, at 17:10, Michael Dykman wrote: > How heavily a given table is queried does not directly affect the index size,

Re: MySQL Indexes

2011-10-07 Thread Neil Tompkins
Can you give more information as to why the second index would be of no use ? On 7 Oct 2011, at 18:24, Michael Dykman wrote: > No, I don't think it can be called. It is a direct consequence of the > relational paradigm. Any implementation of an RDBMS has the same > characteristic. > > - md

Re: MySQL Indexes

2011-10-07 Thread Michael Dykman
No, I don't think it can be called. It is a direct consequence of the relational paradigm. Any implementation of an RDBMS has the same characteristic. - md On Fri, Oct 7, 2011 at 12:20 PM, Reindl Harald wrote: > but could this not be called a bug? > > Am 07.10.2011 18:08, schrieb Michael Dykm

Re: MySQL Indexes

2011-10-07 Thread Reindl Harald
but could this not be called a bug? Am 07.10.2011 18:08, schrieb Michael Dykman: > When a query selects on field_a and field_b, that index can be used. If > querying on field_a alone, the index again is useful. Query on field_b > alone however, that first index is of no use to you. > > On Fri,

Re: MySQL Indexes

2011-10-07 Thread Michael Dykman
How heavily a given table is queried does not directly affect the index size, only the number and depth of the indexes. No, it is not that unusual to have the index file bigger. Just make sure that every index you have is justified by the queries you are making against the table. - md On Fri,

Re: MySQL Indexes

2011-10-07 Thread Michael Dykman
When a query selects on field_a and field_b, that index can be used. If querying on field_a alone, the index again is useful. Query on field_b alone however, that first index is of no use to you. On Fri, Oct 7, 2011 at 10:49 AM, Brandon Phelps wrote: > This thread has sparked my interest. What

Re: MySQL Indexes

2011-10-07 Thread Brandon Phelps
This thread has sparked my interest. What is the difference between an index on (field_a, field_b) and an index on (field_b, field_a)? On 10/06/2011 07:43 PM, Nuno Tavares wrote: Neil, whenever you see multiple fields you'd like to index, you should consider, at least: * The frequency of each

Re: MySQL Indexes

2011-10-07 Thread Tompkins Neil
Is it normal practice for a heavily queried MYSQL tables to have a index file bigger than the data file ? On Fri, Oct 7, 2011 at 12:22 AM, Michael Dykman wrote: > Only one index at a time can be used per query, so neither strategy is > optimal. You need at look at the queries you intend to run

Re: MySQL Indexes

2011-10-06 Thread Nuno Tavares
Neil, whenever you see multiple fields you'd like to index, you should consider, at least: * The frequency of each query; * The occurrences of the same field in multiple queries; * The cardinality of each field; There is a tool "Index Analyzer" that may give you some hints, and I think it's maatk

Re: MySQL Indexes

2011-10-06 Thread Michael Dykman
Only one index at a time can be used per query, so neither strategy is optimal. You need at look at the queries you intend to run against the system and construct indexes which support them. - md On Thu, Oct 6, 2011 at 2:35 PM, Neil Tompkins wrote: > Maybe that was a bad example. If the query

Re: MySQL Indexes

2011-10-06 Thread Neil Tompkins
Maybe that was a bad example. If the query was name = 'Red' what index should I create ? Should I create a index of all columns used in each query or have a index on individual column ? On 6 Oct 2011, at 17:28, Michael Dykman wrote: > For the first query, the obvious index on score will give

Re: MySQL Indexes

2011-10-06 Thread Michael Dykman
For the first query, the obvious index on score will give you optimal results. The second query is founded on this phrase: "Like '%Red%' " and no index will help you there. This is an anti-pattern, I am afraid. The only way your database can satisfy that expression is to test each and every reco