Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jDsPC-0002xh-Be for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 16:15:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDsPB-0000fO-1k for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 16:15:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDsPA-0000fH-9G for pgsql-general@lists.postgresql.org; Mon, 16 Mar 2020 16:15:52 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDsP7-0001ea-CN for pgsql-general@postgresql.org; Mon, 16 Mar 2020 16:15:51 +0000 Received: by mail-lj1-x242.google.com with SMTP id w4so4623631lji.11 for ; Mon, 16 Mar 2020 09:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=h4VVCi+ZkaDKcfPvoZH2W8Ret2uBxgEpXWHUCpGQ1Fw=; b=izY6wZT7hmpxajKg8aS5gJti08TkEjfLcVY70CVodaY+/o/J6NyZFStw361L0+HFKJ MTpxacbG52N7pLLl1p2yBGkAlI5bTzr43aVeltF7iBnxOTD8ariwfij74chE2ELsUnpr HRDociHwGiRl7PoO2kMoRtc/a09+7k/QgQNbuyIqUz0r9ce5nHUW0Zg4bGFbe+KWCLbm 6NOnnMjnuv6ETtPcjg5z8yJPc6W/SLW20Zp28788+/XO5WuwVdeF9b8JVzc3CrOSB7Yw iXjhy1lRTyMost2c+L7qhgbHhhEnHcF/JSIWK227VSfRfPlyIGuxi4+poxZbKtHi7/oG vVeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=h4VVCi+ZkaDKcfPvoZH2W8Ret2uBxgEpXWHUCpGQ1Fw=; b=mS8QaUMRIZZpg95crwlu6HWwY+pwemINTldgRsyZz/MTnejrAX0VX8M09H1I6gyLV1 k2R8MQd5cURYDns84QqF5OxtUyNPza4CpSkUjf7izkJlQFcEDLQb32buEyYLrQDTFDiQ +JPpugMrxi10whGiHzS6zDZammoPTjGFUbXL+PmgPnWggcewW8gFgFEC5m+dohNHSeR5 09AhADpk5VmOQc+Edj+FOzyQ7PZxJa98mK15knZTtAxT/JaecgqtWeWxvPI7BFxc67tK mJjNfptNk+jLtxq7EGWBtgMzzANCqu0ERXsilRuAWnVfnyG24pz/9B1++JACP9e/2RBV +8hA== X-Gm-Message-State: ANhLgQ1oXU5pb1/f1uPzSpnSj7jkMgNE031fvpwBXYegvV6hIktfkger mGJjTS8Fe0FOO94jVLUwvEeOl0H3W3uZww== X-Google-Smtp-Source: ADFU+vvJSO0bFrQakUy1rL5shsqFpwL7shdIz4jlnNJT7tnGPJYOPouuOMuyKSnUBNoes9+FUrYS4Q== X-Received: by 2002:a2e:87cd:: with SMTP id v13mr50411ljj.210.1584375347685; Mon, 16 Mar 2020 09:15:47 -0700 (PDT) Received: from imac.lan (81-227-64-79-no276.tbcn.telia.com. [81.227.64.79]) by smtp.gmail.com with ESMTPSA id c6sm162703ljj.71.2020.03.16.09.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 09:15:46 -0700 (PDT) From: =?utf-8?Q?Bj=C3=B6rn_Lundin?= Message-Id: <72890A04-294E-4753-8839-69F0BAD9AA17@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_E5161E2B-2152-4960-B721-9F6037B9FD9F" Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: Order by and timestamp Date: Mon, 16 Mar 2020 17:15:45 +0100 In-Reply-To: <10f84f23-6011-28ab-79a1-a1c259424d2e@aklaver.com> Cc: Tom Lane , pgsql-general@postgresql.org To: Adrian Klaver References: <63004F55-4CA3-40F8-A898-E7A646B0EBD3@gmail.com> <24142.1584319263@sss.pgh.pa.us> <7D74B8B5-DFBD-4B5B-85C6-A516343E49C1@gmail.com> <346C3B58-D29E-4CC2-8200-691ECA91F494@gmail.com> <10f84f23-6011-28ab-79a1-a1c259424d2e@aklaver.com> X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_E5161E2B-2152-4960-B721-9F6037B9FD9F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 16 mars 2020 kl. 16:46 skrev Adrian Klaver = : >=20 > On 3/16/20 3:03 AM, Bj=C3=B6rn Lundin wrote: >>>> Yeah, it's hard to think of any explanation other than "the query = used a >>>> corrupt index on startts to produce the ordering". But your \d = doesn't >>>> show any index on startts. So maybe there's more than one amarkets >>>> table? >> I realize that I have (basically) the same dataset on another = machine. >=20 > Which brings me back to your first post where you had: >=20 > Timing is on. > AUTOCOMMIT off > psql (9.6.10) > Type "help" for help. >=20 > Then you said the database was: >=20 > version=20 > = --------------------------------------------------------------------------= ---------------------- > PostgreSQL 9.4.15 on x86_64-unknown-linux-gnu, compiled by gcc (Debian = 4.9.2-10) 4.9.2, 64-bit > (1 rad) >=20 > Which seemed to be confirmed by: >=20 > bnl@ibm2:~$ psql > Tidtagning =C3=A4r p=C3=A5. > AUTOCOMMIT off > psql (9.6.15, server 9.4.15) > Skriv "help" f=C3=B6r hj=C3=A4lp. >=20 >=20 > That leaves me wondering how you got to the output in the first post? Ooh - terrible sorry. The output from first post describing the database schema Was actually from my production machine - a raspberry pi. The pi hold a db on an usb-disk, which is pg_dump()ed every night and = imported to ibm2 history db (the bad one)=20 The schema is identical to the one with trouble - which is a history = database Intended for testing I did not realize that would matter when posting - did the post away = from home, I can reach the prod machine but not the history machine (ibm2) from = outside. =20 So - from the pi - first post bnl=3D# \q bnl@pibetbot:~ $ psql Timing is on. AUTOCOMMIT off psql (9.6.10) Type "help" for help. bnl=3D# \d amarkets Table "public.amarkets" Column | Type | = Modifiers =20 = ------------------+--------------------------------+----------------------= ------------------- marketid | character varying(11) | not null default ' = '::character varying marketname | character varying(50) | not null default ' = '::character varying startts | timestamp(3) without time zone | not null eventid | character varying(11) | not null default ' = '::character varying markettype | character varying(25) | not null default ' = '::character varying status | character varying(50) | not null default ' = '::character varying betdelay | integer | not null default 1 numwinners | integer | not null default 1 numrunners | integer | not null default 1 numactiverunners | integer | not null default 1 totalmatched | numeric(15,2) | not null default = 0.0 totalavailable | numeric(15,2) | not null default = 0.0 ixxlupd | character varying(15) | not null default ' = '::character varying ixxluts | timestamp(3) without time zone | not null Indexes: "amarketsp1" PRIMARY KEY, btree (marketid) "amarketsi2" btree (eventid) "amarketsi3" btree (markettype) "amarketsi4" btree (status) "amarketsi5" btree (numwinners) "amarketsi6" btree (ixxluts) bnl=3D# \q bnl@pibetbot:~ $ logout Connection to 192.168.1.7 closed. =46rom the machine (ibm2) with bad sort order imac:~ bnl$ ssh 192.168.1.20 bnl@192.168.1.20's password:=20 Linux ibm2 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u1 (2019-09-20) = x86_64 The programs included with the Debian GNU/Linux system are free = software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. No mail. Last login: Mon Mar 16 16:54:56 2020 from 192.168.1.174 bnl@ibm2:~$ psql Tidtagning =C3=A4r p=C3=A5. AUTOCOMMIT off psql (9.6.15, server 9.4.15) Skriv "help" f=C3=B6r hj=C3=A4lp. bnl=3D> \d amarkets Tabell "public.amarkets" Kolumn | Typ | = Modifierare =20 = ------------------+--------------------------------+----------------------= -------------------- marketid | character varying(11) | inte null default ' = '::character varying marketname | character varying(50) | inte null default ' = '::character varying startts | timestamp(3) without time zone | inte null eventid | character varying(11) | inte null default ' = '::character varying markettype | character varying(25) | inte null default ' = '::character varying status | character varying(50) | inte null default ' = '::character varying betdelay | integer | inte null default 1 numwinners | integer | inte null default 1 numrunners | integer | inte null default 1 numactiverunners | integer | inte null default 1 totalmatched | numeric(15,2) | inte null default = 0.0 totalavailable | numeric(15,2) | inte null default = 0.0 ixxlupd | character varying(15) | inte null default ' = '::character varying ixxluts | timestamp(3) without time zone | inte null Index: "amarketsp1" PRIMARY KEY, btree (marketid) "amarketsi2" btree (eventid) "amarketsi3" btree (markettype) "amarketsi4" btree (status) "amarketsi5" btree (numwinners) "amarketsi6" btree (ixxluts) bnl=3D>=20 -- Bj=C3=B6rn Lundin b.f.lundin@gmail.com --Apple-Mail=_E5161E2B-2152-4960-B721-9F6037B9FD9F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

16 mars 2020 kl. 16:46 skrev Adrian Klaver <adrian.klaver@aklaver.com>:

On 3/16/20 3:03 AM, Bj=C3=B6rn = Lundin wrote:
Yeah, it's hard to think of any explanation other than "the = query used a
corrupt index on startts to produce the = ordering".  But your \d doesn't
show any index on = startts.  So maybe there's more than one amarkets
table?
I realize that = I have (basically) the same dataset on another machine.

Which brings me back to your first post where you = had:

Timing is = on.
AUTOCOMMIT = off
psql = (9.6.10)
Type "help" = for help.

Then you said = the database was:

          &nb= sp;            = ;            &= nbsp;version 
---------------------------------------------------------------= ---------------------------------
PostgreSQL 9.4.15 on x86_64-unknown-linux-gnu, compiled by = gcc (Debian 4.9.2-10) 4.9.2, 64-bit
(1 rad)

Which seemed to be confirmed by:

bnl@ibm2:~$ psql
Tidtagning =C3=A4r = p=C3=A5.
AUTOCOMMIT = off
psql (9.6.15, = server 9.4.15)
Skriv "help" f=C3=B6r hj=C3=A4lp.


That leaves me wondering how you = got to the output in the first post?

Ooh - terrible = sorry.
The output from first post describing the = database schema
Was actually from my production = machine - a raspberry pi.
The pi hold a db on an = usb-disk, which is pg_dump()ed every night and imported to ibm2 history = db (the bad one) 

The schema is identical to the one with trouble - which is a = history database
Intended for testing

I did not realize that = would matter when posting - did the post away from home,
I can reach the prod machine but not the history machine = (ibm2) from outside.
 
So = - from the pi - first post

bnl=3D# \q
bnl@pibetbot:~ $ psql
Timing = is on.
AUTOCOMMIT off
psql = (9.6.10)
Type = "help" for help.

bnl=3D# = \d amarkets
                 =                   Table = "public.amarkets"
  =     Column      |        =       Type            =   |                = Modifiers               =  
------------------+--------------------------------+-----------= ------------------------------
 marketid         | character = varying(11)          | not null default ' = '::character varying
 marketname       | character = varying(50)          | not null default ' = '::character varying
 startts          | = timestamp(3) without time zone | not null
 eventid        =   | character varying(11)          | not = null default ' '::character varying
 markettype       | character = varying(25)          | not null default ' = '::character varying
 status           | character = varying(50)          | not null default ' = '::character varying
 betdelay         | integer  =                     =   | not null default 1
 numwinners       | integer    =                     | = not null default 1
 numrunners       | integer    =                     | = not null default 1
 numactiverunners | integer        =                 | not null = default 1
 totalmatched     | numeric(15,2)    =               | not null default = 0.0
 totalavailable   | numeric(15,2)    =               | not null default = 0.0
 ixxlupd          | character = varying(15)          | not null default ' = '::character varying
 ixxluts          | = timestamp(3) without time zone | not null
Indexes:
    "amarketsp1" PRIMARY KEY, btree = (marketid)
  =   "amarketsi2" btree (eventid)
    "amarketsi3" btree = (markettype)
  =   "amarketsi4" btree (status)
    "amarketsi5" btree = (numwinners)
  =   "amarketsi6" btree (ixxluts)

bnl=3D# \q
bnl@pibetbot:~ $ logout
Connection to 192.168.1.7 closed.

=46rom = the machine (ibm2) with bad sort order


imac:~ = bnl$ ssh 192.168.1.20
bnl@192.168.1.20's = password: 
Linux = ibm2 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u1 (2019-09-20) = x86_64

The = programs included with the Debian GNU/Linux system are free = software;
the = exact distribution terms for each program are described in = the
individual files in = /usr/share/doc/*/copyright.

Debian = GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the = extent
permitted= by applicable law.
No = mail.
Last = login: Mon Mar 16 16:54:56 2020 from 192.168.1.174
bnl@ibm2:~$ psql
Tidtagning =C3=A4r p=C3=A5.
AUTOCOMMIT off
psql (9.6.15, server = 9.4.15)
Skriv = "help" f=C3=B6r hj=C3=A4lp.

bnl=3D>= ; \d amarkets
                 =                   Tabell = "public.amarkets"
  =     Kolumn      |        =       Typ             =   |               Modifierare =                
------------------+--------------------------------+-----------= -------------------------------
 marketid         | character = varying(11)          | inte null default ' = '::character varying
 marketname       | character = varying(50)          | inte null default ' = '::character varying
 startts          | = timestamp(3) without time zone | inte null
 eventid        =   | character varying(11)          | inte = null default ' '::character varying
 markettype       | character = varying(25)          | inte null default ' = '::character varying
 status           | character = varying(50)          | inte null default ' = '::character varying
 betdelay         | integer  =                     =   | inte null default 1
 numwinners       | integer    =                     | = inte null default 1
 numrunners       | integer    =                     | = inte null default 1
 numactiverunners | integer        =                 | inte null = default 1
 totalmatched     | numeric(15,2)    =               | inte null default = 0.0
 totalavailable   | numeric(15,2)    =               | inte null default = 0.0
 ixxlupd          | character = varying(15)          | inte null default ' = '::character varying
 ixxluts          | = timestamp(3) without time zone | inte null
Index:
    "amarketsp1" PRIMARY KEY, btree = (marketid)
  =   "amarketsi2" btree (eventid)
    "amarketsi3" btree = (markettype)
  =   "amarketsi4" btree (status)
    "amarketsi5" btree = (numwinners)
  =   "amarketsi6" btree (ixxluts)

bnl=3D> 





--
Bj=C3=B6rn Lundin




= --Apple-Mail=_E5161E2B-2152-4960-B721-9F6037B9FD9F--