![]() |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Aug 2011
Posts: 103
|
when we created the table and defined the index how many time we think about that mysql take the advantage of that index or not
![]() Example: CREATE TABLE test (id INT, name VARCHAR(100) and defined the index on name (alter table test add index 'name') and in programming code we had written query select * from test where name like '%%' query providing the output which parameter we are passing in it. so can mysql take the benefit of that index if you are saying yes then you are wrong ![]() REASON: BCZ mysql use many wild card and we have not idea which wild card we have to choose, in above example we have choose '%%' wildcard this wildcard is the limitation of indexing if you have defined the index and find the index field with above wildcard then all row will be scanned rather then some specific rows ![]() SOLUTION: So use the post fix wildcard('%')instead of prefix,full text for those fields in which we had defined the index then we can take the benefit of that index otherwise that index nothing for mysql and for us ![]() I believe in practical so do the practice against and enjoy it |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Aug 2011
Posts: 110
|
thanks for sharing this information
|
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2011
Posts: 103
|
pls implement it in your program also
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|