Q: What does the “Query Options” button in Studio 3T do?
The Query Options button makes it easier to turn on disk use and set the collation for a find query.
The Find Query Options dialog is displayed when the icon next to the run query button – in the Collections Tab – is clicked. It will only appear if your MongoDB server is version 4.4 or later.
This dialog enables you to “Allow Disk Use” for the query and to set the collation for the query.
About Allow Disk Use with Studio 3T Query Options
You may have come across the “Allow Disk Use” option in Aggregation before. Some operations need a lot of RAM to work in and RAM is always in short supply. The “Allow Disk Use” option in aggregation lets those operations use temporary disk space to complete their job. You’ll find that option over in Aggregations under its own tab.
MongoDB 4.4 added an option to the find query to let you use disk space if your query was running out of memory. This comes into play when using some aggregation operators or particularly complex sorts.
Access to the option was integrated into Studio 3T with the Find Query Options icon and a check box to “Allow Disk Use” option.
Collation is a way of controlling how MongoDB compares strings, taking into account locale, case, numeric order, white space and other complexities in the process of comparing text strings. Collation has many options and settings, and the first thing to remember is that most of the time you’ll never need to set it because the default collation covers many cases already.
Take this example from MongoDB’s node.js documentation. The locale setting can control how accented characters are handled. So with four French words:
cote < coté < côte < côté
This is their natural binary order, but for Canadian French, the last accent in a word sets the sorting order. So setting locale to Canadian French (fr_CA) would see this sort order:
cote < côte < coté < côté
An important thing to note is that where you do apply a collation to a query (or aggregate) only indexes which have the same collation can be used to speed up the query. Watch out for accidentally mismatching collations in indexes.
If you do need to change collation, the Find Query Options window makes it simple to configure as it consists of drop-down menus with all the possible setting values (and descriptions) for each collation control.
Good to know
Both “Allow Disk Use” and Collation settings are saved with the query and included in query bookmarks so you don’t lose track of them either.
It’s just another way Studio 3T saves you time working with MongoDB.