pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: David Raymond <David.Raymond@tomtom.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs\@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16031: Group by returns duplicate groups
Date: Tue, 01 Oct 2019 16:21:20 +0100
Message-ID: <87sgoclcux.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <VI1PR07MB6029A84A61C5A88328B50AC3879D0@VI1PR07MB6029.eurprd07.prod.outlook.com>
References: <16031-4ef55395a5fbb687@postgresql.org>
	<18850.1569867434@sss.pgh.pa.us>
	<VI1PR07MB602902D7CE166594FC1EF5AE87820@VI1PR07MB6029.eurprd07.prod.outlook.com>
	<VI1PR07MB6029CF9430ECED44CB457E3B87820@VI1PR07MB6029.eurprd07.prod.outlook.com>
	<871rvxm4je.fsf@news-spur.riddles.org.uk>
	<VI1PR07MB6029A84A61C5A88328B50AC3879D0@VI1PR07MB6029.eurprd07.prod.outlook.com>

>>>>> "David" == David Raymond <David.Raymond@tomtom.com> writes:

 David>      c0      |   c1_lt    | c1_eq |   c1_gt    |   c2_lt    | c2_eq |   c2_gt
 David> -------------+------------+-------+------------+------------+-------+------------
 David>  108,565,086 | 27,900,023 |    25 | 80,665,038 | 27,900,023 |    25 | 80,665,038
 David> (1 row)

Well those counts look consistent to me.

But this is all kinds of messed up:

 David> testing=> with sd as (select name, row_number() over (order by name) rnum
 David> testing(>               from big_table)
 David> testing-> select name from sd
 David> testing-> where rnum >= (select min(rnum) from sd where name='DK')
 David> testing-> and rnum <= (select max(rnum) from sd where name='DK')
 David> testing-> and name <> 'DK';
 David>                name
 David> -----------------------------------
 David>  Dk'bus Marine
 David>  Dk's Auto's
 David>  Dk's Bar & Grill
 David>  Dk's Barbers & Stylist
 David>  Dk's Beach Boutique
 David>  Dk's Cabinets & Countertops
 David>  Dk's Cleaning Service
 David>  Dk's Clothing
 David>  Dk's Communications
 David>  Dk's Dancewear & Fitnesswear
 David>  Dk's Dancewear Boutique
 David>  Dk's Discount Dance & Fitnesswear
 David>  DK's Drywall Service
 David>  DK'S DUSTBUSTERS
 David>  Dk's Family Five Star Trophies
 David>  DK's Family Five Star Trophies
 David>  Dk's Food Mart
 David>  Dk'S Group Pte. Ltd.
 David>  Dk's Hair Designs
 David>  Dk's Hair Happenings
 David>  Dk's Hair Supply
 David>  Dk's Home Decor
 David>  DK's Informática
 David>  Dk's Janitorial
 David>  DK's Liquors
 David>  Dk's Market
 David>  Dk's Moda Masculina
 David>  Dk's Nails And Spa
 David>  DK's Pawn Shop
 David>  Dk's Pet Grooming
 David>  DK's Quality Service
 David>  DK's Restoration
 David>  Dk's Sports Center
 David>  Dk's Statuary
 David>  Dk's Style Hut
 David>  Dk's Temiskaming Shore Taxi
 David>  Dk's Towing
 David>  DK's Travel
 David>  Dk'Style
 David>  DK'Z Car Wash
 David>  Dk-
 David> (41 rows)

Let's see some more data from that. Do this query:

with sd as (select name, row_number() over (order by name) rnum
              from big_table)
select rnum, name, encode(convert_to(name, 'SQL_ASCII'),'escape'),
       name < 'DK' as lt, name = 'DK' as eq, name > 'DK' as gt
  from sd
 where rnum >= (select min(rnum) from sd where name='DK')
   and rnum <= (select max(rnum) from sd where name='DK');

-- 
Andrew (irc:RhodiumToad)





view thread (19+ messages)  latest in thread

Message-ID: <87sgoclcux.fsf@news-spur.riddles.org.uk>
Permalink:  ../87sgoclcux.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87sgoclcux.fsf@news-spur.riddles.org.uk

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, David.Raymond@tomtom.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #16031: Group by returns duplicate groups
  In-Reply-To: <87sgoclcux.fsf@news-spur.riddles.org.uk>
  References: <16031-4ef55395a5fbb687@postgresql.org> <18850.1569867434@sss.pgh.pa.us> <VI1PR07MB602902D7CE166594FC1EF5AE87820@VI1PR07MB6029.eurprd07.prod.outlook.com> <VI1PR07MB6029CF9430ECED44CB457E3B87820@VI1PR07MB6029.eurprd07.prod.outlook.com> <871rvxm4je.fsf@news-spur.riddles.org.uk> <VI1PR07MB6029A84A61C5A88328B50AC3879D0@VI1PR07MB6029.eurprd07.prod.outlook.com> <87sgoclcux.fsf@news-spur.riddles.org.uk>

* 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