# Filter to contig

**URL:** https://discuss.hail.is/t/filter-to-contig/1567
**Category:** Hail Query & hailctl
**Created:** [August 4, 2020, 3:22pm UTC](https://discuss.hail.is/t/filter-to-contig/1567 "2020-08-04T15:22:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ch-kr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/ch-kr/32/317_2.png) [@ch-kr](https://discuss.hail.is/u/ch-kr)
#### Post date: [August 4, 2020, 3:22pm UTC](https://discuss.hail.is/t/filter-to-contig/1567/1 "2020-08-04T15:22:06Z")

</div>

Hey hail team,

What is the fastest way to filter a large MatrixTable to a single contig? I have found using this to be faster than using just `filter_intervals` but wanted to see if there is a better way:

```auto
mt = hl.read_matrix_table(mt_path)
mt = hl.filter_intervals(mt, [hl.parse_locus_interval(contig)])
intervals = mt._calculate_new_partitions(n_partitions)
mt = hl.read_matrix_table(
    mt_path, _intervals=intervals
)

```

Thanks!

---

<div class="post-metadata">

### Author: ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)
#### Post date: [August 5, 2020, 7:33pm UTC](https://discuss.hail.is/t/filter-to-contig/1567/2 "2020-08-05T19:33:15Z")

</div>

Sorry, missed this yesterday. The same amount of data is read in both cases, the difference is the partitioning. The calculate\_new\_partitions strategy might give you more parallelism downstream, which could certainly help. This looks fine.

---

<div class="post-metadata">

### Author: ![ch-kr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/ch-kr/32/317_2.png) [@ch-kr](https://discuss.hail.is/u/ch-kr)
#### Post date: [August 5, 2020, 8:09pm UTC](https://discuss.hail.is/t/filter-to-contig/1567/3 "2020-08-05T20:09:30Z")

</div>

thanks!!
