pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Order by and timestamp SOLVED
6+ messages / 3 participants
[nested] [flat]

* Re: Order by and timestamp SOLVED
@ 2020-03-17 07:28  Björn Lundin <b.f.lundin@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Björn Lundin @ 2020-03-17 07:28 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general




>> So insert is
>> bnl@ibm2:~/db$ psql
>> Tidtagning är på.
>> AUTOCOMMIT off
>> psql (9.6.15, server 9.4.15)
>> Skriv "help" för hjälp.
> 
> Except you are using psql 9.6.15 against a 9.4.15 server.
> 
> What happens if you use psql(9.4.15) to do sort query against 9.4.15 server?

So this is more than strange

bnl@ibm2:~$ /usr/lib/postgresql/9.4/bin/psql
Timing is on.
AUTOCOMMIT off
psql (9.4.15)
Type "help" for help.


This. works. I did not realize I ran different client/server versions.
9.6 must have come with a Debian upgrade where I did not migrate the database to 9.6, 
but got the psql 9.6 as default (/sr/bin/psql)


However AFTER I checked the bad sorting - sep/oct 2016 and early apr 2017 
With psql 9.4 I connected with psql 9.6 again.
And now the sorting error is  gone her too!

I cannot reproduce it anymore

So I learned this - always use same version of client and server

Many thanks to Adrian and Tom


--
Björn Lundin
b.f.lundin@gmail.com

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Order by and timestamp SOLVED
@ 2020-03-17 14:05  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Björn Lundin <b.f.lundin@gmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Tom Lane @ 2020-03-17 14:05 UTC (permalink / raw)
  To: Björn Lundin <b.f.lundin@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

=?utf-8?Q?Bj=C3=B6rn_Lundin?= <b.f.lundin@gmail.com> writes:
>> What happens if you use psql(9.4.15) to do sort query against 9.4.15 server?

> However AFTER I checked the bad sorting - sep/oct 2016 and early apr 2017 
> With psql 9.4 I connected with psql 9.6 again.
> And now the sorting error is  gone her too!

Boy ... I don't have any confidence in that answer.  psql does not re-sort
data, nor does it have any way to affect what the server does.  It seems
to me that if this actually is a version inconsistency problem, that's
a bug in itself.

I am starting to wonder though if you had psql's FETCH_COUNT option
active in one configuration and not the other, and if so whether that
could explain anything.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Order by and timestamp SOLVED
@ 2020-03-17 14:39  Björn Lundin <b.f.lundin@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Björn Lundin @ 2020-03-17 14:39 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

17 mars 2020 kl. 15:05 skrev Tom Lane <tgl@sss.pgh.pa.us>:
> 
> =?utf-8?Q?Bj=C3=B6rn_Lundin?= <b.f.lundin@gmail.com> writes:
>>> What happens if you use psql(9.4.15) to do sort query against 9.4.15 server?
> 
>> However AFTER I checked the bad sorting - sep/oct 2016 and early apr 2017 
>> With psql 9.4 I connected with psql 9.6 again.
>> And now the sorting error is  gone her too!
> 
> Boy ... I don't have any confidence in that answer.

It is not an answer. It is an observation.

>  psql does not re-sort
> data, nor does it have any way to affect what the server does.

I did not say that. I do not think that.
But - still I got the above result
* bad order with psql 9.6 towards db 9.4
* good order with psql 9.4 towards db 9.4
* good order with psql 9.6 towards db 9.4

>  It seems
> to me that if this actually is a version inconsistency problem, that's
> a bug in itself.
> I am starting to wonder though if you had psql's FETCH_COUNT option
> active in one configuration and not the other, and if so whether that
> could explain anything.

FETCH_COUNT is a variable set in runtime / read by .psqlrc?
Then it is the same. 
I have 1 .psqlrc on ibm2.

bnl@ibm2:~$ locate .psqlrc
/home/bnl/.psqlrc
bnl@ibm2:~$ 

bnl@ibm2:~$ cat .psqlrc
\timing 
\set AUTOCOMMIT 'off' 
\echo 'AUTOCOMMIT' :AUTOCOMMIT



But I do notice that in .psqlrc_history I see strange ’040’ - sometimes 
bnl@ibm2:~$ cat .psql_history
_HiStOrY_V2_
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040amarkets\040order\040by\040startts;
select * from amarkets order by startts;  
select\040*\040from\040amarkets\040order\040by\040startts;



So I now did 
bnl@ibm2:~$ find / -name psql
/usr/lib/postgresql/9.4/bin/psql
/usr/lib/postgresql/9.6/bin/psql
^C
bnl@ibm2:~$ /usr/lib/postgresql/9.4/bin/psql
Timing is on.
AUTOCOMMIT off
psql (9.4.15)
Type "help" for help.

bnl=> select * from AEVENTS order by OPENTS;
<output omitted, was ok. Different statement too see if that is added to .psql_history>
Time: 278,207 ms


bnl@ibm2:~$ cat .psqlrc
\timing 
\set AUTOCOMMIT 'off' 
\echo 'AUTOCOMMIT' :AUTOCOMMIT

bnl@ibm2:~$ cat .psql_history
_HiStOrY_V2_
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040amarkets\040order\040by\040startts;\040\040
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040AEVENTS\040order\040by\040OPENTS;

And yes it is
Trying 9.6

bnl@ibm2:~$ /usr/lib/postgresql/9.6/bin/psql
Tidtagning är på.
AUTOCOMMIT off
psql (9.6.15, server 9.4.15)
Skriv "help" för hjälp.

bnl=> select * from AEVENTS order by OPENTS limit 1;
<output omitted, was ok. Different statement again too see if that is added to .psql_history>
Tid: 19,240 ms
bnl=> ^D\q



bnl@ibm2:~$ cat .psql_history
_HiStOrY_V2_
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040amarkets\040order\040by\040startts;\040\040
select\040*\040from\040amarkets\040order\040by\040startts;
select\040*\040from\040AEVENTS\040order\040by\040OPENTS;
select\040*\040from\040AEVENTS\040order\040by\040OPENTS\040limit\0401;
bnl@ibm2:~$ 

And now that one too.


I will move from this machine.

Thanks for the suggestions, both Tom and Adrian

I will keep the machine if you are interested of pursuing it,
Otherwise I’ll stop his thread.
That is, I am convinced enough that mixing versions combined with perhaps old hardware
together did something strange

--
Björn Lundin
b.f.lundin@gmail.com

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Order by and timestamp SOLVED
@ 2020-03-17 15:50  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Björn Lundin <b.f.lundin@gmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Adrian Klaver @ 2020-03-17 15:50 UTC (permalink / raw)
  To: Björn Lundin <b.f.lundin@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general

On 3/17/20 12:28 AM, Björn Lundin wrote:
> 
> 
> 
>>> So insert is
>>> bnl@ibm2:~/db$ psql
>>> Tidtagning är på.
>>> AUTOCOMMIT off
>>> psql (9.6.15, server 9.4.15)
>>> Skriv "help" för hjälp.
>>
>> Except you are using psql 9.6.15 against a 9.4.15 server.
>>
>> What happens if you use psql(9.4.15) to do sort query against 9.4.15 
>> server?
> 
> So this is more than strange
> 
> bnl@ibm2:~$ /usr/lib/postgresql/9.4/bin/psql
> Timing is on.
> AUTOCOMMIT off
> psql (9.4.15)
> Type "help" for help.
> 
> 
> This. works. I did not realize I ran different client/server versions.
> 9.6 must have come with a Debian upgrade where I did not migrate the 
> database to 9.6,
> but got the psql 9.6 as default (/sr/bin/psql)
> 
> 
> However AFTER I checked the bad sorting - sep/oct 2016 and early apr 2017
> With psql 9.4 I connected with psql 9.6 again.
> And now the sorting error is  gone her too!
> 
> I cannot reproduce it anymore
> 
> So I learned this - always use same version of client and server

I made the suggestion to try the same psql version as the server because 
I had run out of ideas. It is usually not an issue to mix and match 
psql/server versions. In fact the Debian/Ubuntu packaging will by 
default use the latest psql to connect to all versions installed as it 
is backwards compatible. I have also gone the other way older psql/newer 
server, you just lose any added features from the newer psql.

I am still not sure that this can be marked solved. I am trying to 
figure out how running a different version of psql once can affect 
another version of psql. That would seem to imply psql changed something 
on the server and AFAIK sorting/ordering is done by the server not the 
client.

> 
> Many thanks to Adrian and Tom
> 
> 
> --
> Björn Lundin
> b.f.lundin@gmail.com <mailto:b.f.lundin@gmail.com>
> 
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Order by and timestamp SOLVED
@ 2020-03-17 15:57  Björn Lundin <b.f.lundin@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Björn Lundin @ 2020-03-17 15:57 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general



> 
> I am still not sure that this can be marked solved. I am trying to figure out how running a different version of psql once can affect another version of psql. That would seem to imply psql changed something on the server and AFAIK sorting/ordering is done by the server not the client.
> 

Ok if you want, I can
* keep the server as is
* give you ssh access to it

Let me know, and I’ll mail you (privately) login details 
I am going to move the data, and I have the whole set of daily pg_dumps I need to set it up elsewhere. 

--
Björn Lundin
b.f.lundin@gmail.com

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Order by and timestamp SOLVED
@ 2020-03-17 22:42  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Björn Lundin <b.f.lundin@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Adrian Klaver @ 2020-03-17 22:42 UTC (permalink / raw)
  To: Björn Lundin <b.f.lundin@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general

On 3/17/20 8:57 AM, Björn Lundin wrote:
> 
> 
>>
>> I am still not sure that this can be marked solved. I am trying to 
>> figure out how running a different version of psql once can affect 
>> another version of psql. That would seem to imply psql changed 
>> something on the server and AFAIK sorting/ordering is done by the 
>> server not the client.
>>
> 
> Ok if you want, I can
> * keep the server as is
> * give you ssh access to it

Well, some digging around at the above confirmed that the date sorting 
is working correctly now. The only thing I could find is what I take to 
be a discrepancy between the 9.4 and 9.6 instances of psql. Namely that 
the 9.4 instance does not have a link to libm:

linux-vdso.so.1 (0x00007ffc381f5000)
libpq.so.5 => /usr/lib/x86_64-linux-gnu/libpq.so.5 (0x00007fd35f958000)
libssl.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 
(0x00007fd35f6f7000)
libedit.so.2 => /usr/lib/x86_64-linux-gnu/libedit.so.2 (0x00007fd35f4bf000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd35f120000)
libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 
(0x00007fd35eeb4000)
libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 
(0x00007fd35ea1a000)
libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 
(0x00007fd35e7cf000)
libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 
(0x00007fd35e57e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007fd35e361000)
libcrypto.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 
(0x00007fd35df65000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd35dd61000)
libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 
(0x00007fd35db3e000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fd35d914000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fd35d6fe000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd35fe07000)
libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fd35d424000)
libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 
(0x00007fd35d1f1000)
libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 
(0x00007fd35cfed000)
libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 
(0x00007fd35cde1000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 
(0x00007fd35cbdd000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fd35c9c6000)
liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 
(0x00007fd35c7b7000)
libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 
(0x00007fd35c59c000)
libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 
(0x00007fd35c203000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd35bffb000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd35bde1000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 
(0x00007fd35bb7c000)
libidn.so.11 => /lib/x86_64-linux-gnu/libidn.so.11 (0x00007fd35b948000)
libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 
(0x00007fd35b735000)
libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 
(0x00007fd35b4fe000)
libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 
(0x00007fd35b2c9000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fd35b046000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fd35ae3d000)


> 
> Let me know, and I’ll mail you (privately) login details
> I am going to move the data, and I have the whole set of daily pg_dumps 
> I need to set it up elsewhere.
> 
> --
> Björn Lundin
> b.f.lundin@gmail.com <mailto:b.f.lundin@gmail.com>
> 
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2020-03-17 22:42 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 07:28 Re: Order by and timestamp SOLVED Björn Lundin <b.f.lundin@gmail.com>
2020-03-17 14:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-03-17 14:39   ` Björn Lundin <b.f.lundin@gmail.com>
2020-03-17 15:50 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-03-17 15:57   ` Björn Lundin <b.f.lundin@gmail.com>
2020-03-17 22:42     ` Adrian Klaver <adrian.klaver@aklaver.com>

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