[SERVER-3215] Anonymous Garbage Collected/Temporary Collection Created: 07/Jun/11  Updated: 06/Dec/22  Resolved: 25/Mar/19

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Moses Nakamura Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 10
Labels: collection
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-1153 Create an in-memory only storage engine Closed
Assigned Teams:
Query
Participants:

 Description   

It would be useful to be able to create temporary anonymous collections, in order to fake big transactions.

Right now (in java) I am using the hack of running a .find() on a new collection that I make, and then a .toArray() on the cursor that is returned, and then inserting the resulting list to my main collection. Then I drop my collection. But even if I forgot to drop the collection, it would be nice for it to disappear. Also, it is annoying to have to generate a random string to support multithreading this.



 Comments   
Comment by Craig Homa [ 25/Mar/19 ]

We believe that the aggregation $out feature supports this.

Comment by Asya Kamsky [ 05/Dec/17 ]

Aggregation has supported $out option which may be used for this since version 2.6.

Comment by Ilya Shaisultanov [ 04/Oct/13 ]

This would be very useful for containing intermediate states/operations which then go to the final collection. I'm researching right now how to do that manually because that's something we have to do.

Comment by SlugFiller [ 21/Jun/12 ]

This is necessary for any large aggregation. Imagine the MySQL equivalent:
SELECT * FROM a INNER JOIN b ON (b.key=a.b_key) INNER JOIN c ON (c.key=a.c_key) INNER JOIN d ON (d.key=c.d_key) WHERE a.type='stuff_type' ORDER BY a.stuff, b.stuff, c.stuff LIMIT 5000, 20
In the above case, MySQL creates a temporary table including the (quite large) result set, sorts in on-disk, and then returns the result's subset.

In Mongo, since there is no join, such a query can and should be done using many smaller queries which take the original subset, and adds the necessary information, sorts the resulting information, and finally returns the required subset. However, unless the table/collection "a" is small enough to be fully contained in memory (which it usually isn't), a temporary collection must be formed in order to hold the result set prior to extracting the required subset.

Generated at Thu Feb 08 03:02:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.