Re: Strange limit and offset behaviour....

Поиск
Список
Период
Сортировка
От Bjørn T Johansen
Тема Re: Strange limit and offset behaviour....
Дата
Msg-id 20090207225719.07a4240d@pennywise.havleik.no
обсуждение исходный текст
Ответ на Re: Strange limit and offset behaviour....  ("Adam Rich" <adam.r@sbcglobal.net>)
Ответы Re: Strange limit and offset behaviour....
Список pgsql-general
On Sat, 7 Feb 2009 15:49:49 -0600
"Adam Rich" <adam.r@sbcglobal.net> wrote:

> >
> > I have the following sql:
> >
> > SELECT * from table order by dato asc limit 20 offset 0
> >
> >
> > This gives me different rows than the 20 first rows when running the
> > following sql:
> >
> > SELECT * from table order by dato asc
> >
> >
> > Shouldn't the 20 first rows in the second sql statment be the same 20
> > rows that is returned in the first statement
> > or am I missing something?
> >
>
> Not necessarily.  In your example query, if "dato" was not a unique
> column, and there were some duplicates, the "top 20" values is not
> a defined set.  Adding the offset clause might cause a different
> query plan, resulting in a different ordering of the duplicate values.
>
>
I found out that if I created an index on the dato field, then I got the same 20 rows... Does that make sense or is
it just a coincedense?

BTJ

В списке pgsql-general по дате отправления:

Предыдущее
От: "Adam Rich"
Дата:
Сообщение: Re: Strange limit and offset behaviour....
Следующее
От: Grzegorz Jaśkiewicz
Дата:
Сообщение: Re: Strange limit and offset behaviour....