Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/88535-secondary-indexing-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.