Re: SQL select query becomes slow when using limit (with no offset) - Mailing list pgsql-performance

From PFC
Subject Re: SQL select query becomes slow when using limit (with no offset)
Date
Msg-id op.uxxm37opcigqcu@soyouz
Whole thread Raw
In response to SQL select query becomes slow when using limit (with no offset)  (Kees van Dieren <keesvandieren@gmail.com>)
List pgsql-performance
> The query:
> select events_events.id FROM events_events
> left join events_event_types on events_events.eventType_id=
> events_event_types.id
> where events_event_types.severity=70
> and events_events.cleared='f'
> order by events_events.dateTime DESC

    The main problem seems to be lack of a suitable index...

- Try creating an index on events_events( eventType_id, cleared )
- Or the other way around : events_events( cleared, eventType_id )

    (depends on your other queries)

    Please try both and report EXPLAIN ANALYZE.

pgsql-performance by date:

Previous
From: Greg Stark
Date:
Subject: Re: SQL select query becomes slow when using limit (with no offset)
Next
From: Jerry Champlin
Date:
Subject: Re: load / stress testing