Thank you for this course

Thanks to everyone at MongoDB U for another great course!

I do have a couple of questions that I have been meaning to ask:

If SINGLE_SHARD is returned via an explain query, doesn’t that indeed mean that the query is a targeted, rather than a scatter-gather query? The reason why I’m asking is that I originally had the correct answer for final question #6, but then I decided to create a new key on my mongos as a test so I could run the queries via my local Vagrant environment. When I ran each of the queries (with the new shard key that I had created ({ "sku": 1, "_id": 1 })), the output for each explain query returned SINGLE_SHARD. This is what prompted me to (against my better judgment) to change my answer at the last minute. Isn’t is possible for a query that does not use the shard key prefix to be a targeted query?

Another thing that confused me was the statement ( Lab - Detect Scatter Gather Queries) performs an index scan before the sharding filter. Part of the output of my explain query looked like this:

    	"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : 
                         "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"keyPattern" : {
									"sku" : 1
								},

From the way it reads, it appears that the IXSCAN comes after the SHARDING_FILTER. Obviously, I read into this incorrectly. What is the proper way of interpreting this?

One last question:

Does anyone have any advice for installing the Vagrant environment on an external hard drive? …Seems like it might be a pain, but I’d like to look into it for future courses here at MongoDB (as a way to free up hard drive space).

Thanks again for this course! I have learned a lot and I may even want to take this course again in the future as a way to further my understanding of what I have learned here.

Cheers:-)

Juliette

2 Likes
  1. If the query doesn’t use the shard key, it can’t be targeted. The idea is that the shard key allows you to ignore shards which are irrelevant.

  2. It was the fact that the query could be met with an index scan, and that index scan was the shard key. Unfortunately there is no single statement to say it is a targeted query, which is what I deduced from that question.

    So even though the query might have query all the shards, it was still a targeted query, it was just it would have targeted all the shards.

    A scatter query is a query that has no clue which shard the data is on. So it is asking all and sundry.

    I did what you did and added a compound index (once before I had assumed something on a question in a lab, and had nearly got caught out).

    However, I compared the results of the ranged query explain plan, the one where it queries on a range of countries (I used “type” and “sku” for my compound index), with the results of the 2 queries we did in the lab - detect scatter gather. It was the same as the one I expected.

  3. You read the explain plan, from the inside out. The most indented parts are executed first. Yes it my least favourite document to read.

3 Likes

Hi @NMullins,

Thank you for taking the time to respond to my questions! With regards to my first question, I get it now: no query can be targeted (no matter what) without a shard key. I did understand that at first, but I had to go and complicate things (:smile:) and ended up with the wrong answer. I won’t forget it now though.

You read the explain plan, from the inside out. The most indented parts are executed first.

OMG! I was reading everything in reverse. Thanks for pointing that out to me.

Cheers:-)

1 Like

Hopefully what I have told you is correct, and if not hopefully someone will step in and correct me :slight_smile:

Given the importance of the explain function and the plans it gives, hopefully the Performance course will provide a detailed run down on this.

2 Likes

The performance course will indeed go into this some more :slight_smile:

Also @juliettet, you can definitely move the VMs to an external drive. Just shunt the whole directory tree where you put the VMs onto the drive.

Mind you, this most likely will affect performance of the VMs.

2 Likes

Thank you @NMullins!. I’m going to look over my notes from when I took the Performance course. I need a refresher.

Cheers:-)

Hi @Tess_Sluijter,

Thanks for the tips/advice on moving my VMs over to an external drive. I’m going to have to look into that, although I’m thinking that it might be more of an aggravation than a net benefit if the VMs are slooooooow :smile:

Cheers:-)

1 Like