Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do? - Mailing list pgsql-performance

From Jeff Janes
Subject Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do?
Date
Msg-id CAMkU=1wz0Rp3Ac4Z3u8tQ-RZLdfVwdxWtUAd_ze5tN9yc=LDvw@mail.gmail.com
Whole thread Raw
In response to [PERFORM] Please help with a slow query: there are millions of records, whatcan we do?  (Pat Maddox <pat@adorable.io>)
Responses Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do?
List pgsql-performance
On Tue, Mar 7, 2017 at 6:26 PM, Pat Maddox <pat@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

pgsql-performance by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do?
Next
From: Dinesh Chandra 12108
Date:
Subject: [PERFORM] Auto generate number in Postgres-9.1.