[SERVER-28060] Some words make simple full text search very slow Created: 21/Feb/17  Updated: 23/Feb/17  Resolved: 23/Feb/17

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

Type: Bug Priority: Major - P3
Reporter: Sergey Kazankov Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-26833 Permit non-blocking $text queries whe... Closed
Operating System: ALL
Participants:

 Description   

Full text search is very slow:

> db.poi.find({"$text":{"$search":"printer"}}, {'_id': 1}).limit(10);
{ "_id" : ObjectId("56f32ef56e95524b6cf81bc5") }
{ "_id" : ObjectId("5628e2d3a8a0845397884d55") }
{ "_id" : ObjectId("56f2e6b76e95524b6ccd4eae") }
{ "_id" : ObjectId("56f2f6936e95524b6cd73cd3") }
{ "_id" : ObjectId("56f331c16e95524b6cf9acb1") }
{ "_id" : ObjectId("55eec042a8a08408a451110a") }
{ "_id" : ObjectId("55eed93aa8a08408a4537784") }
{ "_id" : ObjectId("55eeee94a8a0843cfd754ff7") }
{ "_id" : ObjectId("5628ae67a8a084539786d10e") }
{ "_id" : ObjectId("56f2e4566e95524b6ccbd042") }
Fetched 10 record(s) in 4183ms

4 seconds on such query is very big time. Ok, it is passably, but...

> db.poi.find({"$text":{"$search":"cafe"}}, {'_id': 1}).limit(10);
{ "_id" : ObjectId("566bc1c1a8a084299e635ebb") }
{ "_id" : ObjectId("567214bda8a0840b52f10708") }
{ "_id" : ObjectId("566bb446a8a084299e627dd8") }
{ "_id" : ObjectId("56f2ee7c6e95524b6cd230b0") }
{ "_id" : ObjectId("56f32c7f6e95524b6cf6c3e3") }
{ "_id" : ObjectId("56f2ed706e95524b6cd18ad4") }
{ "_id" : ObjectId("566bb670a8a084299e6298d2") }
{ "_id" : ObjectId("566bc1f6a8a084299e6361ea") }
{ "_id" : ObjectId("566bc618a8a084299e63af4e") }
{ "_id" : ObjectId("56f307f96e95524b6ce1b8ca") }
Fetched 10 record(s) in 271405ms

This is madness!

My environment:

> version();
3.4.2
> db.poi.count();
26929589
> db.poi.getIndexes();
...
{
		"v" : 1,
		"key" : {
				"_fts" : "text",
				"_ftsx" : 1
		},
		"name" : "text_index",
		"ns" : "poi.poi",
		"default_language" : "english",
		"weights" : {
				"name" : 1,
				"shortAddr" : 1,
				"tags.types" : 1
		},
		"language_override" : "language",
		"textIndexVersion" : 3
}
...
 
> db.stats();
{
        "db" : "poi",
        "collections" : 9,
        "views" : 0,
        "objects" : 65770165,
        "avgObjSize" : 681.1554679846097,
        "dataSize" : 44799707520,
        "storageSize" : 22752616448,
        "numExtents" : 0,
        "indexes" : 88,
        "indexSize" : 10810482688,
        "ok" : 1
}

Storage engine is default (wired tiger).



 Comments   
Comment by Kelsey Schubert [ 23/Feb/17 ]

Hi kazankov,

Thanks for the additional information. Text search stage currently executes in a blocking fashion, which delays the first batch from being returned to the client. SERVER-26833 would improve this behavior when score projection is not requested. Please feel free to vote for SERVER-26833 and watch it for updates.

Kind regards,
Thomas

Comment by Sergey Kazankov [ 22/Feb/17 ]

> db.poi.find({"$text":{"$search":"printer"}}, {'_id': 1}).itcount();

1053

> db.poi.find({"$text":{"$search":"cafe"}}, {'_id': 1}).itcount();

482249

Comment by Kelsey Schubert [ 21/Feb/17 ]

Hi kazankov,

Would you please provide the output of the following commands?

db.poi.find({"$text":{"$search":"printer"}}, {'_id': 1}).itcount()
db.poi.find({"$text":{"$search":"cafe"}}, {'_id': 1}).itcount()

Thank you,
Thomas

Generated at Thu Feb 08 04:17:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.