From: Tom Lane <tgl@sss.pgh.pa.us>
To: Szűcs Gábor <surrano@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Wrong index used when ORDER BY LIMIT 1
Date: Wed, 21 Dec 2005 14:34:19 -0500
Message-ID: <15421.1135193659@sss.pgh.pa.us> (raw)
In-Reply-To: <43A998D4.4070300@gmail.com>
References: <43A998D4.4070300@gmail.com>
=?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= <surrano@gmail.com> writes:
> Query is:
> SELECT idopont WHERE muvelet = x ORDER BY idopont LIMIT 1.
Much the best solution for this would be to have an index on
(muvelet, idopont)
--- perhaps you can reorder the columns of "muvelet_vonalkod_muvelet"
instead of making a whole new index --- and then say
SELECT idopont WHERE muvelet = x ORDER BY muvelet, idopont LIMIT 1
PG 8.1 can apply such an index to your original query, but older
versions will need the help of the modified ORDER BY to recognize
that the index is usable.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, surrano@gmail.com
Subject: Re: Wrong index used when ORDER BY LIMIT 1
In-Reply-To: <15421.1135193659@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox