Dear all,


The option MAXLEN tricked me today which is why I need some advice.

I have the problem that I have a query that normally works smoothly but with one certain data set, it's really slow. I think it's because at some point in the query I am trying to match a value from the index that is cut due to MAXLEN of 96 (I made a test: the query is fast for values below 96, but 97 and above is slow). So I followed the documentation and created the database again with a MAXLEN of 200 instead. What tricked me was that whenever I optimize the database, MAXLEN is back to 96.


The documentation says about MAXLEN:

"Specifies the maximum length for strings to be stored in index structures. The value of this option will be assigned once to a new database, and can *only be changed* by creating a new database or doing a full optimization."

I assumed "full optimization" means db:optimize with $all is true(). But I noticed that the value of MAXLEN also changes when I do db:optimize without true().
For Optimization, the documentation states:
If I understand correctly from the last bullet point, it says that the MAXLEN option is not considered from the original database as it's an index option. For the second bullet point I would not say though, that "nothing will be done", if the database is completely up-to-date. Because when I create a new database "test" with a MAXLEN of 200 and do a db:optimize("test"), MAXLEN goes back to 96.
How to keep MAXLEN at the value I set? Do I have to set it every time, I do an optimization? Like db:optimize("test", map {"maxlen": 200})? That seems to work but it feels a bit over the top, considering that I have many queries with optimizations that I would need to adapt for this one data set then. What is the reason for resetting MAXLEN during optimization? 

Best wishes,

Julia