Unexpected behaviour of ORDER BY and LIMIT/OFFSET

From: Ognjen Blagojevic <ognjen(at)etf(dot)bg(dot)ac(dot)yu>
To: pgsql-novice(at)postgresql(dot)org
Subject: Unexpected behaviour of ORDER BY and LIMIT/OFFSET
Date: 2009-05-14 18:28:01
Message-ID: 4A0C62B1.1060208@etf.bg.ac.yu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all,

I'm having a problem with LIMITed queries, and I don't know is it me who
is doing something wrong or Postgres. (Probably me.)

When I browse through the list of employees:

id id_dept name
-------------------
1 1 Tom
2 1 Mike
3 2 Meggie
4 2 Marge
5 3 Bart
6 3 Lisa
7 4 Homer

using LIMITed selects like:

SELECT * FROM employee ORDER BY id_dept LIMIT 3
SELECT * FROM employee ORDER BY id_dept LIMIT 3 OFFSET 3
SELECT * FROM employee ORDER BY id_dept LIMIT 3 OFFSET 6

it seems that Meggie is not in the result list on any of the SELECTs.
From the first query I get Tom, Mike and Marge, and then from the
second Marge, Bart and Lisa.

Is this expected behavior?

My configuration is: CentOS 5.3 and Postgres 8.3.7.

Regards,
Ognjen

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2009-05-14 18:50:40 Re: Unexpected behaviour of ORDER BY and LIMIT/OFFSET
Previous Message Mark 2009-05-14 11:13:17 'Hot' backup of PostgreSQL dbases