ronz Posted January 30, 2008 Share Posted January 30, 2008 I think I'm using MySQL version 4.1. (The web host info wasn't completely clear) The question is this: I have a table with about 20K entries. The primary index has two keys - usercode and event. There is a secondary index of just usercode. Some questions: 1) Is that secondary index necessary? I.e. if I want to get all of the rows for a user, will the primary index with the two columns be sufficient for that? In other words, does an index with two columns act like an index with one column if only the first column is specified in the select statement? 2) It appears that when I do a group query for a user it takes longer than it should. I.e. it acts as if there is no index. I'm wondering if it's not using the secondary index because the usercode is in the primary index? 3) Is there a way to tell MySQL which index to use for a query? 4) When I specify an index with two columns, it will arrange the index in the sequence I specify as opposed to the sequence the columns appear in the row - yes? Quote Link to comment https://forums.phpfreaks.com/topic/88535-secondary-indexing-question/ Share on other sites More sharing options...
fenway Posted January 30, 2008 Share Posted January 30, 2008 1) No, it's not necessary. 2) Post the query. 3) Yes, but it's generally a bad idea. 4) Yes. Quote Link to comment https://forums.phpfreaks.com/topic/88535-secondary-indexing-question/#findComment-453559 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.