On Tue, Mar 7, 2017 at 6:26 PM, Pat Maddox <p...@adorable.io> wrote:

> Hi there,
>
> I’ve been asked to help with a project dealing with slow queries. I’m
> brand new to the project, so I have very little context. I’ve gathered as
> much information as I can.
>
> I’ve put the schema, query, and explain info in gists to maintain their
> formatting.
>
> We are stumped with this slow query right now. I could really use some
> help looking for ways to speed it up.
>
> If you need any more information, please let me know.
>


You could try a partial index on:

(account_id, completed_at desc, taskable_name, position,
assigned_to_user_id) where "tasks"."archived" != 't' AND "tasks"."complete"
= 't'

Also, the poor estimate of the number of rows on your scan of
index_permissions_on_user_id_and_object_id_and_object_type suggests that
you are not analyzing (and so probably also not vacuuming) often enough.

Cheers,

Jeff

Reply via email to