LIMIT not showing all results

From: Casey Deccio <casey(at)deccio(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: LIMIT not showing all results
Date: 2019-03-05 16:10:50
Message-ID: 85CFAA9E-E10B-4B1E-8C79-7793CC92BA82@deccio.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Okay, the subject is a little misleading because of course LIMIT isn't supposed to all results, but I've got an issue where LIMIT isn't showing the number of results I would expect. For example:

mydb=> select id,name,date from analysis where name = 'foo' order by date desc limit 3;
id | name | date
-----------+-------------+------------------------
195898786 | foo | 2019-03-05 06:45:29+00
(1 row)

mydb=> select id,name,date from analysis where name = 'foo' order by date desc limit 20;
id | name | date
-----------+-------------+------------------------
195898786 | foo | 2019-03-05 06:45:29+00

But when I query without limit (or even with "limit all"), there are more:

mydb=> select id,name,date from analysis where name = 'foo' order by date desc;
id | name | date
-----------+-------------+------------------------
195898786 | foo | 2019-03-05 06:45:29+00
195842671 | foo | 2019-01-24 14:31:45+00
195667475 | foo | 2018-12-30 23:40:11+00
195256709 | foo | 2018-10-29 18:33:07+00
...
(Many more rows)

psql version 9.6.11.
Server version 9.4.20.

We just migrated the database from one server to another (as far as I know, there was no version change), and it worked previously.

Any ideas?

Many thanks in advance.
Casey

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2019-03-05 16:15:55 Re: [External] LIMIT not showing all results
Previous Message Perumal Raj 2019-03-05 16:09:12 Re: Question about pg_upgrade from 9.2 to X.X