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

2017-03-07 Thread Pat Maddox
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 slo

Re: [PERFORM] Huge difference between ASC and DESC ordering

2017-03-07 Thread twoflower
Thank you Jeff. Jeff Janes wrote > Did you force PostgreSQL to stop using the index on s.id? If not, do > that. If so, please post the EXPLAIN (analyze) of the plan it does switch > to. Yes, this finishes in 20 seconds, which is two times faster than *order by id asc*. Query plan: Jeff