Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB. [Key Too Large To Index]

Some Background: I'm planning to use MongoDB as the publishing frontend db for a few of my websites. The actual data will be kept in a SQL Server db and there will be background jobs that will populate the MongoDB at predefined time intervals for readonly purposes to boost website performance.

The Situation: I have a table 'x' that i translated into a mongo collection, everything worked fine.

'x' has a column 'c' that was originally a NVARCHAR(MAX) in the source db and has multilingual text in it.

When I was searching by column 'c', mongo was doing fullscan on the collection.

So I tried doing an ensureIndex({c : 1 }) which worked but when I checked the mongodb logs it showed me that 90% of the data could not be indexed as [Key Too Large To Index] !!

And thus is has indexed 10% of the data and now only returns results from that 10% !!

What are my alternatives ??

Note: I was using this column to do full text searching in SQL Server, now im not sure if I should go ahead with Mongo or not :(

like image 273
Storm Avatar asked Jun 16 '11 06:06

Storm


1 Answers

Try to run your mongod process with this parameter:

sudo mongod --setParameter failIndexKeyTooLong=false

And than try again.

like image 59
Robert Reiz Avatar answered Nov 20 '22 00:11

Robert Reiz