how to speed up mongoengine queries
<p>If I have two objects like:</p>

<pre><code>class User(Document):
    name = StringField()
    following = ListField(ReferenceField('User'))
    meta = {
        'indexes': [
            'following',
        ]
    }

class Media(Document):
    owner = ReferenceField('User')
    url = StringField()
    is_hidden = BooleanField()
    posted_date = Date

    meta = {
        'indexes': [
            'owner',
            'posted_date',
            'is_hidden',
        ]
    }
</code></pre>

<p>and when I want to look up the following condition where it is not hidden and its owner is someone I am following and it was recently posted, I have a query like this:</p>

<pre><code>user = User.objects.first()
Media.objects(Q(owner__in=user.following) &amp;
              Q(is_hidden=False) &amp;
              Q(posted_date__gte=dt.now()-dt.timedelta(days=3))
</code></pre>

<p>which is not scaling and is becoming much slower.  What can I do to speed up the performance of these types of complex queries?</p>