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 1jDsCv-0002U4-1y for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 16:03:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDsCt-0005b4-T0 for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 16:03:11 +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 1jDsCt-0005aw-IQ for pgsql-general@lists.postgresql.org; Mon, 16 Mar 2020 16:03:11 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDsCr-0004qK-B7 for pgsql-general@postgresql.org; Mon, 16 Mar 2020 16:03:11 +0000 Received: by mail-lj1-x233.google.com with SMTP id u12so19298314ljo.2 for ; Mon, 16 Mar 2020 09:03:08 -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=/sLq8F8uJaZdmAXiNr/dZemdNVoI6g8/CMXz8ZbxLf0=; b=SnT1lGTpKIIRf/nEc1pJurFdIpiKLGtgt26StJpHPVLqTc7v+u5jh4AY8AHNbsUDkZ bcSWaA5hx5tmm+r/hW0QRQ951Dteqk1IAPjR3clVeHR5G6FeFmGwD4jGHkZr2tRsRRxE zSJ5UDQIYpFmsh2xwWhFCOD5a7K6ZzBLemyfsfE/x6M+XeZnGET9GKLRGuXjOLEgNcHa ogj4BDjGt7AScEnAnHHwKdlVhr53Khc4z/M5GZJrggYNQvPBuVI19ZNUofz13oXRdsL7 3X9LUFITkSQx5xT7E8WU8CiRu6YVJCETMqkA91NaL/zLNI9bCBv9Bqg1ybNYXn/y7WUy tsPA== 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=/sLq8F8uJaZdmAXiNr/dZemdNVoI6g8/CMXz8ZbxLf0=; b=k60iySN8fTAfzLQiM9gk2wUMpi2gAkYhkDtLSku5m6CA3ViFmd8oQAyHeF90pbbcM1 XYb7aG1ulJ5BBDMFTOWKznwsiRmQYkg+DR3BUTkEuWQSEv56f6EeNBYqr6Lhjmi8FEMY byOGo2hFL9ZxQKcmCdIMF33ozYnOOm83Kz66qXWbIjSICSNhRExvOhQ3BrkWDDG27Djb I9cRH02np3dXvxoIYl+ehAY4rCbTPo90jK5j6btqy7xYht5X6Fh40NlB8xL2FlQfH3Jp iOG9+1L9+Wo6hgsunXXQtmw6+2ctUOxnicWhcTv2txIJk04Lkq8r/paIVjRdU9V6UXR4 tD4A== X-Gm-Message-State: ANhLgQ3JuzUQVOyahPXn8Y0qSL062W5ObIhWzXyVsgWqRCwTYXayngNv ZEIW5s7E3e3bJylGaNIo/nQ= X-Google-Smtp-Source: ADFU+vsMD8YAI76UuSETNCpjbgH6hKONF//Au54uV1vJUK1rWILGMCjcfezJ7fPCh+bMzhmJlYO14g== X-Received: by 2002:a2e:9982:: with SMTP id w2mr10488lji.11.1584374586469; Mon, 16 Mar 2020 09:03:06 -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 203sm146575ljf.65.2020.03.16.09.03.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 09:03:05 -0700 (PDT) From: =?utf-8?Q?Bj=C3=B6rn_Lundin?= Message-Id: <116B8B6D-5619-460C-92B1-471602AC0357@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_E014ED51-3D6E-498C-A2D2-8D97A6EE9FBD" 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:03:04 +0100 In-Reply-To: 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> X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_E014ED51-3D6E-498C-A2D2-8D97A6EE9FBD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 16 mars 2020 kl. 16:27 skrev Adrian Klaver = : >=20 > On 3/16/20 1:51 AM, Bj=C3=B6rn Lundin wrote: >>> 16 mars 2020 kl. 01:41 skrev Tom Lane >: >>>=20 >>> Adrian Klaver > writes: >>>> On 3/15/20 2:33 PM, Bj=C3=B6rn Lundin wrote: >>>>> I then did =E2=80=99select * from AMARKETS order by STARTTS=E2=80=99= >>>=20 >>>> Is amarkets in more then one schema? >>>=20 >>> 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? >> Yes - in other schemas - described in reply to Adrain >> But the schema_path does not point to them >> And those two other tables are empty >>> Another possibly-useful bit of evidence is to see what EXPLAIN shows = as >>> the query plan for this query. >> bnl=3D> explain select * from amarkets order by startts; >=20 > Can you run as: >=20 > explain analyze select * from amarkets order by startts; Yes, below the first plan >=20 >> QUERY PLAN >> = ----------------------------------------------------------------------- >> Sort (cost=3D10702.57..10939.29 rows=3D94691 width=3D106) >> Sort Key: startts >> -> Seq Scan on amarkets (cost=3D0.00..2875.91 rows=3D94691 = width=3D106) >> (3 rader) >> =E2=80=94 bnl=3D> explain analyze select * from amarkets order by startts; QUERY PLAN = =20 = --------------------------------------------------------------------------= --------------------------------------------- Sort (cost=3D10702.57..10939.29 rows=3D94691 width=3D106) (actual = time=3D404.555..422.174 rows=3D97835 loops=3D1) Sort Key: startts Sort Method: quicksort Memory: 24329kB -> Seq Scan on amarkets (cost=3D0.00..2875.91 rows=3D94691 = width=3D106) (actual time=3D4.586..351.739 rows=3D97835 loops=3D1) Planning time: 74.707 ms Execution time: 434.785 ms (6 rader) Tid: 527,142 ms bnl=3D>=20 -- Bj=C3=B6rn Lundin b.f.lundin@gmail.com --Apple-Mail=_E014ED51-3D6E-498C-A2D2-8D97A6EE9FBD Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

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

On = 3/16/20 1:51 AM, Bj=C3=B6rn Lundin wrote:
16 mars = 2020 kl. 01:41 skrev Tom Lane <tgl@sss.pgh.pa.us <mailto:tgl@sss.pgh.pa.us>>:

Adrian Klaver <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> writes:
On 3/15/20 2:33 PM, = Bj=C3=B6rn Lundin wrote:
I then did =E2=80=99select * from AMARKETS order by = STARTTS=E2=80=99

Is amarkets in more then = one schema?

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?
Yes - in other schemas - described in reply to = Adrain
But the schema_path does not point to them
And those two other tables are empty
Another possibly-useful bit of evidence is to = see what EXPLAIN shows as
the query plan for this = query.
bnl=3D> explain select * from = amarkets order by startts;

Can = you run as:

explain analyze select * from = amarkets order by startts;
Yes, below the first plan


  =                     =         QUERY PLAN
---------------------------------------------------------------= --------
 Sort  (cost=3D10702.57..10939.29 = rows=3D94691 width=3D106)
   Sort Key: = startts
   ->  Seq Scan on = amarkets  (cost=3D0.00..2875.91 rows=3D94691 width=3D106)
(3 rader)
=E2=80=94


bnl=3D> explain analyze select * from amarkets order by = startts;
  =                     =                     =             QUERY PLAN      =                     =                     =          
---------------------------------------------------------------= --------------------------------------------------------
 Sort  = (cost=3D10702.57..10939.29 rows=3D94691 width=3D106) (actual = time=3D404.555..422.174 rows=3D97835 loops=3D1)
   Sort Key: = startts
   Sort Method: quicksort  Memory: = 24329kB
   ->  Seq Scan on amarkets  = (cost=3D0.00..2875.91 rows=3D94691 width=3D106) (actual = time=3D4.586..351.739 rows=3D97835 loops=3D1)
 Planning time: 74.707 = ms
 Execution time: 434.785 ms
(6 rader)

Tid: 527,142 ms
bnl=3D> 




=
--
Bj=C3=B6rn Lundin




= --Apple-Mail=_E014ED51-3D6E-498C-A2D2-8D97A6EE9FBD--