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 1jDmbK-00017H-49 for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 10:04:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDmbI-0001f4-UK for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 10:04:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDmbI-0001dR-GE for pgsql-general@lists.postgresql.org; Mon, 16 Mar 2020 10:04:00 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDmbG-0001rb-2B for pgsql-general@postgresql.org; Mon, 16 Mar 2020 10:04:00 +0000 Received: by mail-lf1-x143.google.com with SMTP id c20so13501748lfb.0 for ; Mon, 16 Mar 2020 03:03:57 -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=R8WFSn/3KEnqr0mMca6q9TtU5mNl216lN4xsUO743+8=; b=Djnil5+1mnyl/olwwME16jMYUg1oiUOE2V50h80+7sjfSHwHYglPE1gNSooSs4LK27 oO3gjtac7U2SCH+Lo/rvYbjEmORnH09hs00Cfgj0tT9apbIs8dqmsk17emmaPTQ/1dF/ e0S1zI3x+plDgfdwN+sPrL0sUPzpeTvx31lf42o6GPRUdZXB2z93+6kRpSQg8l1r13rh c/OCEOwH0gUO5JBhChg7z6zfiYHZki1m9cXHXT5rkaNUXl5HNANqSlBQ5U7ZeOkGJFTX /cX3swbFKN9UyilpGGlahJjhUs0gswi1Noi5Rq47PMViSrDWCFrUzvZm61TC1ccu2SeU lUOA== 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=R8WFSn/3KEnqr0mMca6q9TtU5mNl216lN4xsUO743+8=; b=KEmWPfJsp+H8W6IXb71TiifSIxVgagNxBma3HzbFwqWaa9xzyWrwRBBYIWXvuh/P7x vlW+m4Lg+J7pSfD3CNnA3TnRT3aanafheeR8YFIAJzxkzBv0kFyYWghbECR6VNgWnyFo /xGEjaewMeUFLn8Lgr7qqLcZ35fb/Xnn8cLp5SyOQyBpzDNP/w0ywFUF8Hca8KvssL66 hIOfa5ZcEa0XQv/MyhrCTui3ahElzGlYwnRseerwWZ1XEgOnKGuQm04wVCTC6uURD/CM ZPUfAKKa+YyAnA78Ze/ujnqN6sEmEvedczpgY3ZtwhDkna3+/vFjE5dAqUjgVIDQYhWb s5lQ== X-Gm-Message-State: ANhLgQ3oppca6yGqiEwVwqCeiVG9pbiHYhEyGnEIwKIE/PgBg8l+qTYv AavZoyHxCg7x8qQ1csWWIg2CN8l9D6ndYg== X-Google-Smtp-Source: ADFU+vuu1iyyk2c9lO6h93mpXaqe4enPI6pkzCU1Lg2ZL+4Nb6/xVYUE3Rg/c2g+lNE6hh+5PprPtQ== X-Received: by 2002:a05:6512:1095:: with SMTP id j21mr16753728lfg.124.1584353037002; Mon, 16 Mar 2020 03:03:57 -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 k14sm21746357lfg.96.2020.03.16.03.03.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 03:03:56 -0700 (PDT) From: =?utf-8?Q?Bj=C3=B6rn_Lundin?= Message-Id: <346C3B58-D29E-4CC2-8200-691ECA91F494@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_19CA6153-D61F-403C-975C-277CE848C239" Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: Order by and timestamp Date: Mon, 16 Mar 2020 11:03:55 +0100 In-Reply-To: <7D74B8B5-DFBD-4B5B-85C6-A516343E49C1@gmail.com> Cc: Adrian Klaver , pgsql-general@postgresql.org To: Tom Lane References: <63004F55-4CA3-40F8-A898-E7A646B0EBD3@gmail.com> <24142.1584319263@sss.pgh.pa.us> <7D74B8B5-DFBD-4B5B-85C6-A516343E49C1@gmail.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=_19CA6153-D61F-403C-975C-277CE848C239 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >> 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. bnl=3D# select version(); version = =20 = --------------------------------------------------------------------------= ----------------------------------------------------- PostgreSQL 10.6 (Ubuntu 10.6-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, = compiled by gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0, 64-bit (1 row) bnl@tp:~$ uname -a Linux tp 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 = x86_64 x86_64 x86_64 GNU/Linux It misses som later record (from 2020) but otherwise contains the same = data, and same definition It is also the only user-database on the system bnl=3D# \d amarkets Table "public.amarkets" Column | Type | Collation | = Nullable | Default =20 = ------------------+--------------------------------+-----------+----------= +------------------------ marketid | character varying(11) | | not = null | ' '::character varying marketname | character varying(50) | | not = null | ' '::character varying startts | timestamp(3) without time zone | | not = null |=20 eventid | character varying(11) | | not = null | ' '::character varying markettype | character varying(25) | | not = null | ' '::character varying status | character varying(50) | | not = null | ' '::character varying betdelay | integer | | not = null | 1 numwinners | integer | | not = null | 1 numrunners | integer | | not = null | 1 numactiverunners | integer | | not = null | 1 totalmatched | numeric(15,2) | | not = null | 0.0 totalavailable | numeric(15,2) | | not = null | 0.0 ixxlupd | character varying(15) | | not = null | ' '::character varying ixxluts | timestamp(3) without time zone | | not = null |=20 Indexes: "amarketsp1" PRIMARY KEY, btree (marketid) "amarketsi2" btree (eventid) "amarketsi3" btree (markettype) "amarketsi4" btree (status) "amarketsi5" btree (numwinners) "amarketsi6" btree (ixxluts) This gets it correctly. So it points to something on the first machine. Recreating indexes is a possibility, but (to me) a bit unintuitive since = there are no index on startts I=E2=80=99ll do that tomorrow. -- Bj=C3=B6rn Lundin b.f.lundin@gmail.com --Apple-Mail=_19CA6153-D61F-403C-975C-277CE848C239 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8


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?
<= div>

I realize that I = have (basically) the same dataset on another machine.

bnl=3D# select = version();
  =                     =                     =                   version =                     =                     =                   =  
---------------------------------------------------------------= ----------------------------------------------------------------
 PostgreSQL 10.6 (Ubuntu = 10.6-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu = 7.3.0-16ubuntu3) 7.3.0, 64-bit
(1 = row)

bnl@tp:~$ uname -a
Linux tp 4.15.0-39-generic #42-Ubuntu = SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 = GNU/Linux


It misses som later record (from 2020) but = otherwise contains the same data, and same definition
It is = also the only user-database on the system

bnl=3D# = \d amarkets
  =                     =                 Table = "public.amarkets"
  =     Column      |        =       Type            =   | Collation | Nullable |        Default  =        
------------------+--------------------------------+-----------= +----------+------------------------
 marketid         | character = varying(11)          |       =     | not null | ' '::character varying
 marketname       | = character varying(50)          |     =       | not null | ' '::character = varying
 startts          | = timestamp(3) without time zone |           | = not null | 
 eventid          | character = varying(11)          |       =     | not null | ' '::character varying
 markettype       | = character varying(25)          |     =       | not null | ' '::character = varying
 status           | character = varying(50)          |       =     | not null | ' '::character varying
 betdelay       =   | integer                =         |           | not = null | 1
 numwinners       | integer    =                     | =           | not null | 1
 numrunners       | = integer                  =       |           | not null | = 1
 numactiverunners | integer        =                 |     =       | not null | 1
 totalmatched     | numeric(15,2)    =               |       =     | not null | 0.0
 totalavailable   | numeric(15,2)    =               |       =     | not null | 0.0
 ixxlupd          | character = varying(15)          |       =     | not null | ' '::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)


This gets it = correctly.

So it points to = something on the first machine.
Recreating indexes is a = possibility, but (to me) a bit unintuitive since there are no index on = startts
I=E2=80=99ll do that tomorrow.


--
Bj=C3=B6rn Lundin




= --Apple-Mail=_19CA6153-D61F-403C-975C-277CE848C239--