# Performance issues with party\_relationship module

**URL:** https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212
**Category:** Developer
**Created:** [January 20, 2025, 7:09am UTC](https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212 "2025-01-20T07:09:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [January 20, 2025, 7:09am UTC](https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212/1 "2025-01-20T07:09:01Z")

</div>

Hi, Im experiencing some issues with the `party_relationship` module activated.  
When defining several relations on a party (around +100), if I try to create a sale for example, to a party which is related to the party with several relations, fields with:

```auto
search_context={
          'related_party': Eval('party'),
          }

```

(`shipment_party`, `incoterm_location`…) takes minutes to load records, I guess its directly caused by `Party._distance_query` but I’m not really sure on how to fix it.  
I’m experiencing the issue on a 6.8 server, and I recreated it on the 7.4 demo; creating a sale with the party with id 11, raise:  
`Error: "[502] Bad Gateway". Try again later.` on the client.  
Any idea? Thanks.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 20, 2025, 9:24am UTC](https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212/2 "2025-01-20T09:24:26Z")

</div>

On the demo server I see no slow down nor gateway errors.

By default the party relationship search for relation up to 7 degrees so if the relationship network is dense and there are a lot of parties, this may be slow as almost all parties will be in relationship with all the parties.

---

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [January 20, 2025, 9:28am UTC](https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212/3 "2025-01-20T09:28:20Z")

</div>

> [@ced](#):
>
> On the demo server I see no slow down nor gateway errors.

I do.

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/a/aadb92ca7221efad76ea5de4d80dfba9283e696b.png)

---

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [February 6, 2025, 12:44pm UTC](https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212/4 "2025-02-06T12:44:52Z")

</div>

> By default the party relationship search for relation up to 7 degrees

I did not understand this as first and I left this topic to work on other things, I just read it again and find out about [Party Relationship Module — Party Relationship module for Tryton](https://docs.tryton.org/7.0/modules-party-relationship/#configuration)  
Decreasing the depth solves the problem.  
Thanks.

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [February 7, 2025, 12:45pm UTC](https://discuss.tryton.org/t/performance-issues-with-party-relationship-module/8212/5 "2025-02-07T12:45:21Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
