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

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do?
Дата
Msg-id CAMkU=1wz0Rp3Ac4Z3u8tQ-RZLdfVwdxWtUAd_ze5tN9yc=LDvw@mail.gmail.com
обсуждение исходный текст
Ответ на [PERFORM] Please help with a slow query: there are millions of records, whatcan we do?  (Pat Maddox <pat@adorable.io>)
Ответы Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do?
Список 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 по дате отправления:

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: Re: [PERFORM] Please help with a slow query: there are millions ofrecords, what can we do?
Следующее
От: Dinesh Chandra 12108
Дата:
Сообщение: [PERFORM] Auto generate number in Postgres-9.1.