From: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
---|---|
To: | Pat Maddox <pat(at)adorable(dot)io> |
Cc: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Please help with a slow query: there are millions of records, what can we do? |
Date: | 2017-03-08 18:00:47 |
Message-ID: | CAMkU=1wz0Rp3Ac4Z3u8tQ-RZLdfVwdxWtUAd_ze5tN9yc=LDvw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Tue, Mar 7, 2017 at 6:26 PM, Pat Maddox <pat(at)adorable(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Dinesh Chandra 12108 | 2017-03-20 13:38:40 | Auto generate number in Postgres-9.1. |
Previous Message | Albe Laurenz | 2017-03-08 10:05:07 | Re: Please help with a slow query: there are millions of records, what can we do? |