perftools / xhgui

Web interface for XHProf profiling data can store data in MongoDB or PDO database
1.65k stars 342 forks source link

MongoSearcher - preserve indexes on truncate #406

Closed codespill closed 3 years ago

codespill commented 3 years ago

Description

When truncating MongoDB, collections are dropped, therefore all indexes are lost. This pull request propose using remove() method instead of drop(), which will remove all documents whilst preserving indexes.

Additional info

Documentation on remove() method:

To delete all documents in a collection, pass an empty document ({}).

Source: https://docs.mongodb.com/manual/reference/method/db.collection.remove/

glensc commented 3 years ago

Squashed fixup commits, added helper to remove duplication in tests. LGTM