# Data Locality and Sharded Indexes

**URL:** <https://discuss.elastic.co/t/data-locality-and-sharded-indexes/5089>\
**Category:** Elasticsearch\
**Created:** [August 8, 2011, 8:47pm UTC](https://discuss.elastic.co/t/data-locality-and-sharded-indexes/5089 "2011-08-08T20:47:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Chong](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@Tony\_Chong](https://discuss.elastic.co/u/Tony_Chong)\
**Post date:** [August 8, 2011, 8:47pm UTC](https://discuss.elastic.co/t/data-locality-and-sharded-indexes/5089/1 "2011-08-08T20:47:48Z")

</div>

Hello,

I read in one of the posts that splitting up the index into more shards,  
generally improves indexing performance. Is this because all shards of the  
index are read at the same time simultaneously when doing a search?

#2, So if I have 4 nodes (node1, 2 3 and 4) and 1 index with 4 shards, 0  
replication, if I do a search against node1 with data that resides on node  
4, how will this work? or does the shard on a box, only contain the data it  
has locally.

Sorry if this doesn't make sense. New to elasticsearch.

Tony

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 9, 2011, 9:23am UTC](https://discuss.elastic.co/t/data-locality-and-sharded-indexes/5089/2 "2011-08-09T09:23:21Z")

</div>

If you have 4 nodes, and 4 shards no replicas, then you will have a shard  
allocated per node. When you execute a search, it will be broadcast to all  
shards, execute on each one ("locally"), and then aggregate the results.

Several shards improve indexing performance if you have enough machines to  
have the shards allocated on them. This is simply because indexing  
operation, different than search, just goes to one shard, so the indexing  
process will end up split across more nodes.

Note, with routing, you can actually control even for search on which shards  
a search will execute on.

On Mon, Aug 8, 2011 at 11:47 PM, Tony Chong [tonyjchong@gmail.com](mailto:tonyjchong@gmail.com) wrote:

> Hello,
> 
> I read in one of the posts that splitting up the index into more shards,  
> generally improves indexing performance. Is this because all shards of the  
> index are read at the same time simultaneously when doing a search?
> 
> #2, So if I have 4 nodes (node1, 2 3 and 4) and 1 index with 4 shards, 0  
> replication, if I do a search against node1 with data that resides on node  
> 4, how will this work? or does the shard on a box, only contain the data it  
> has locally.
> 
> Sorry if this doesn't make sense. New to elasticsearch.
> 
> Tony

---

<div class="post-metadata">

**Author:** ![Tony\_Chong](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@Tony\_Chong](https://discuss.elastic.co/u/Tony_Chong)\
**Post date:** [August 9, 2011, 5:56pm UTC](https://discuss.elastic.co/t/data-locality-and-sharded-indexes/5089/3 "2011-08-09T17:56:25Z")

</div>

Thanks Shay. Exactly the information I was looking for!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:57am UTC](https://discuss.elastic.co/t/data-locality-and-sharded-indexes/5089/4 "2017-07-06T03:57:42Z")

</div>

Closed on July 6, 2017, 3:57am UTC


