green giant
06-17-2006, 10:12 AM
I will be given 20 chars as a unique input, let's just call it my sessionID (it isn't). I cannot change my source to give me an int of some kind instead.
From this sessionID, I need to retrieve the row data. The problem, of course, is that a 20 char comparison is very expensive.
If I literally convert this 20 char string to an int using ASCII values, the resulting value will be far too large for any computer to handle.
Do I have any alternatives as far as the backend goes?
maxymizer
06-17-2006, 11:23 AM
Just create an index on that column..
green giant
06-17-2006, 12:17 PM
I assume that would have been fairly obvious considering how I asked the best way to index that column, but thanks.
maxymizer
06-17-2006, 12:37 PM
Maybe I don't understand what's the problem..if index on that column allready exists, I don't know what other kind of optimisation you can do (as I assumed you DIDN'T create the index on that column).
This comparision is similar to forum auth systems where they compare 32 chars long hashed password against entry in database, which is just a plain indexed column.
Maybe someone can offer some other optimisation, but as far my knowledge goes - creating the index is everything you can do.
orbitz
06-17-2006, 06:23 PM
I will be given 20 chars as a unique input, let's just call it my sessionID (it isn't). I cannot change my source to give me an int of some kind instead.
From this sessionID, I need to retrieve the row data.
Why did you have to use this 20 chars as an unique id? like the other one said, use another index for it.
green giant
06-17-2006, 06:39 PM
I am passed this as an index from an outside source. I have no control over it.
It's like using MySQL's INET_ATON function to store an IP address as an unsigned int instead of a 16 byte char string. I'm simply wondering if there's any optimization technique I can use here.
gogocode
06-17-2006, 06:43 PM
alter table foo add index myindex (foobar);
However remember that you need to create a minimal set of indexes on the table which cover as many possibe query forms as possible as a result of the way that MySQL uses indexes (one index per table per query, only fields appearing in a consecutive group startng at the left of the index will be used).