Jump to content

Secondary indexing question


ronz

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.