There is a contradiction in your question. You indicate that you cannot separate and store them in separate columns, but then you are talking about indexing both parts separately - you cannot do this without breaking them.
I see you really have two options:
- Saving them in separate columns
- Hash output to reduce index memory
Ideally, you should store them in two columns and create a composite index if you always look for them together in the same order. In this case, it is difficult to give accurate advice without first specifying more information - however, as a rule, a username, a time stamp will make logical sense if you request a user or change it if you want to request a time stamp. You can also create an index for each column if you need to search one or the other.
Hashing the created string
INSERT INTO table (crc_hash_column, value_column_name) values (CRC32(@generated_value), @generated_value)
will reduce the size to a 32-bit integer (only 4 index bytes per line), which is much smaller than the required VARCHAR or CHAR space.
If you take this approach, then you must take measures to avoid collisions, because of the Paradox of Birthday it will happen, and most likely, as your data set grows. Even in a collision, additional filtering will still provide more performance considering the size of the index than the alternatives.
SELECT * FROM table WHERE crc_hash_column = CRC32(@search_value) AND value_column_name = @searchvalue
Using a hash will lead to several more processor cycles, but the CRC32 hash is very fast, so even though you have to rephrase each time you search, this extra work is tiny for the benefits of indexing large amounts of data.
In general, I would prefer the first option, but it is almost impossible to recommend without knowing your precedent.
You should look at both parameters and see if they meet your requirements.