Skip site navigation (1) Skip section navigation (2)

Re: SQL select query becomes slow when using limit (with no offset)

From: PFC <lists(at)peufeu(dot)com>
To: "Kees van Dieren" <keesvandieren(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: SQL select query becomes slow when using limit (with no offset)
Date: 2009-07-31 12:46:45
Message-ID: op.uxxm37opcigqcu@soyouz (view raw or flat)
Thread:
Lists: 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.

In response to

pgsql-performance by date

Next:From: Jerry ChamplinDate: 2009-07-31 14:04:45
Subject: Re: load / stress testing
Previous:From: Greg StarkDate: 2009-07-31 12:42:26
Subject: Re: SQL select query becomes slow when using limit (with no offset)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group