Re: How to get the selectStatement parse tree info?

2022-10-24 Thread Julien Rouhaud
Hi,

On Tue, Oct 25, 2022 at 01:38:09PM +0800, jack...@gmail.com wrote:
> I'm reading this book https://www.interdb.jp/pg/pgsql03.html? I'm debugging
> pg, but I can't get the parse tree like this:
> https://files.slack.com/files-pri/T0FS7GCKS-F047H5R2UKH/1.png, can you give
> me some ways to get that? I'm using vscode to debug, the watch info doesn't
> interest me, it gives me
> nothing,https://files.slack.com/files-pri/T0FS7GCKS-F048MD5BTME/quzk_6bk0sug60__f_0wh2l.png

I can't access the pictures, so I'm not sure what exactly you expect (and you
should usually prefer sending text anyway), but maybe what you want is "SET
debug_print_parse = on" to print the parse trees in the logs?




How to get the selectStatement parse tree info?

2022-10-24 Thread jack...@gmail.com
I'm reading this book https://www.interdb.jp/pg/pgsql03.html? I'm debugging pg, 
but I can't get the parse tree like this:
https://files.slack.com/files-pri/T0FS7GCKS-F047H5R2UKH/1.png, can you give me 
some ways to get that? I'm using vscode to debug, 
the watch info doesn't interest me, it gives me 
nothing,https://files.slack.com/files-pri/T0FS7GCKS-F048MD5BTME/quzk_6bk0sug60__f_0wh2l.png


jack...@gmail.com


Re: possible bug

2022-10-24 Thread Alvaro Herrera
On 2022-Oct-21, Tom Lane wrote:

> "David G. Johnston"  writes:
> > On Fri, Oct 21, 2022 at 4:52 PM Ravi Krishna  wrote:
> >> on a diff note, is the word memoize inspired from Perl Module memoize
> >> which use to do the same thing.
> 
> > It is a general functional programming concept - not sure on the history
> > but probably academic and thus Perl and others picked it up "from the
> > source".
> 
> Looks to me like you suggested our use of the terminology:
> 
> https://www.postgresql.org/message-id/flat/CAKFQuwZQmCNyS_Vv2Jf3TNe7wRTiptWNs7xkgU%3DAEdqthkQe9A%40mail.gmail.com#bbcd739c97e28b17ef2e111be8cf214b

The word itself has been used in the PG lists before.  For example,
Greg Stark used it in 2008 when discussing WITH RECURSIVE
https://postgr.es/m/47c151f1.8050...@enterprisedb.com
There are a few other hits over the years.

-- 
Álvaro Herrera PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Digital and video cameras have this adjustment and film cameras don't for the
same reason dogs and cats lick themselves: because they can."   (Ken Rockwell)




Re: Explain returns different number of rows

2022-10-24 Thread Vince McMahon
Thanks for the clarification, Peter.



On Sat, Oct 22, 2022, 05:32 Peter J. Holzer  wrote:

> On 2022-10-20 09:56:23 -0700, Christophe Pettus wrote:
> > On Oct 20, 2022, at 09:52, Vince McMahon 
> wrote:
> > > The number of rows are different.
> >
> > This isn't unexpected.  EXPLAIN does not actually run the query and
> > determine how many rows are returned; it calculates an estimate based
> > on the current system statistics, which vary constantly depending on
> > activity in the database.
>
> EXPLAIN ANALYZE (which is what he did) does run the query and return the
> actual number of rows:
>
> #v+
> wdsah=> explain (analyze, buffers) select * from
> facttable_eurostat_comext_cpa2_1 ;
>
> ╔══╗
> ║QUERY
> PLAN║
>
> ╟──╢
> ║ Seq Scan on facttable_eurostat_comext_cpa2_1  (cost=0.00..1005741.32
> rows=39633432 width=85) (actual time=0.396..6541.701 rows=39633591 loops=1)
> ║
> ║   Buffers: shared read=609407
> ║
> ║ Planning Time: 1.650 ms
> ║
> ║ Execution Time: 7913.027 ms
> ║
>
> ╚══╝
> (4 rows)
> #v-
>
> The first tuple (cost=0.00..1005741.32 rows=39633432 width=85) is an
> estimate used to plan the query. But the second one
> (actual time=0.396..6541.701 rows=39633591 loops=1)
> contains measurements from actually running the query.
>
> I think it's possible that the rows estimate in the first tuple changes
> without any actual data change (although the only reason I can think of
> right now would be an ANALYZE (in another session or by autovacuum)).
> But the actual rows definitely shouldn't change.
>
> hp
>
> --
>_  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
>


Re: PostgreSql Service different path

2022-10-24 Thread Peter J. Holzer
On 2022-10-24 15:51:30 +0800, chris navarroza wrote:
> sudo yum install postgresql14-server postgresql14-contrib
[...]
> /usr/pgsql-14/bin/initdb -D /home/dmartuser/pgsql/14/data
> 
> and update the postgresql.conf to the new path, now when I start the service,
> it has an error and when I check it says 
[doesn't use /home/dmartuser/pgsql/14/data]
> 
> How can I point the service to read the new path ( /home/dmartuser/pgsql/14/
> data )? 

Check the systemd configuration file for this service.

hp


-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature


Re: PostgreSql Service different path

2022-10-24 Thread Jeffrey Walton
On Mon, Oct 24, 2022 at 6:38 AM chris navarroza
 wrote:
>
> I install postgresql14.5 with the following commands
>
> sudo yum install postgresql14-server postgresql14-contrib
>
>
> sudo su postgres
>
> cd /tmp
>
> /usr/pgsql-14/bin/initdb -D /home/dmartuser/pgsql/14/data
>
> and update the postgresql.conf to the new path, now when I start the service, 
> it has an error and when I check it says
>
> -- Unit postgresql-14.service has begun starting up.
> Oct 24 15:16:45 datamartds postgresql-14-check-db-dir[132338]: 
> "/var/lib/pgsql/14/data/" is missing or empty.
> Oct 24 15:16:45 datamartds postgresql-14-check-db-dir[132338]: Use 
> "/usr/pgsql-14/bin/postgresql-14-setup initdb" to initialize the database 
> cluster.
> Oct 24 15:16:45 datamartds postgresql-14-check-db-dir[132338]: See 
> /usr/share/doc/postgresql14/README.rpm-dist for more information.
> Oct 24 15:16:45 datamartds systemd[1]: postgresql-14.service: Control process 
> exited, code=exited status=1
> Oct 24 15:16:45 datamartds systemd[1]: postgresql-14.service: Failed with 
> result 'exit-code'.
>
> How can I point the service to read the new path ( 
> /home/dmartuser/pgsql/14/data )?

The startup script that is calling systemd should perform a `mkdir -p
/var/lib/pgsql/14/data` before calling the PostgreSQL binary.

Jeff




GIN Index use statistic information?

2022-10-24 Thread 黄宁
Hi:
I create a new type for myself and create a gin index for its array type.
I want to know :
1. how to use statistic info in build index for a table?
2. how to use analyze to generate statistic information?


PostgreSql Service different path

2022-10-24 Thread chris navarroza
Hi,

I install postgresql14.5 with the following commands


sudo yum install postgresql14-server postgresql14-contrib


sudo su postgres

cd /tmp

/usr/pgsql-14/bin/initdb -D /home/dmartuser/pgsql/14/data
and update the postgresql.conf to the new path, now when I start the
service, it has an error and when I check it says

-- Unit postgresql-14.service has begun starting up.
Oct 24 15:16:45 datamartds postgresql-14-check-db-dir[132338]:
*"/var/lib/pgsql/14/data/"
is missing or empty.*
Oct 24 15:16:45 datamartds postgresql-14-check-db-dir[132338]: Use
"/usr/pgsql-14/bin/postgresql-14-setup initdb" to initialize the database
cluster.
Oct 24 15:16:45 datamartds postgresql-14-check-db-dir[132338]: See
/usr/share/doc/postgresql14/README.rpm-dist for more information.
Oct 24 15:16:45 datamartds systemd[1]: postgresql-14.service: Control
process exited, code=exited status=1
Oct 24 15:16:45 datamartds systemd[1]: postgresql-14.service: Failed with
result 'exit-code'.

How can I point the service to read the new path (
/home/dmartuser/pgsql/14/data )?

Thanks,

Chris Albert Navarroza
Information Technology Officer I
CTCO - ITDS - RDMD


Re: Upgrading error

2022-10-24 Thread chris navarroza
This is the log I got.
-
  pg_upgrade run on Mon Oct 24 07:41:13 2022
-

command: "/usr/pgsql-12/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D
"/home/dmartuser/pgdata/data" -o "-p 50432 -b -c
config_file=/var/lib/pgsql/12/data/postgresql.conf -c listen_addresses=''
-c unix_socket_permissions=0700 -c unix_socket_directories='/tmp'" start >>
"pg_upgrade_server.log" 2>&1
waiting for server to start2022-10-23 23:41:13.458 GMT [107444] LOG:
 skipping missing configuration file
"/home/dmartuser/pgdata/data/postgresql.auto.conf"
2022-10-24 07:41:13.459 PST [107444] LOG:  starting PostgreSQL 12.9 on
x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat
8.5.0-4), 64-bit
2022-10-24 07:41:13.460 PST [107444] LOG:  listening on Unix socket
"/tmp/.s.PGSQL.50432"
2022-10-24 07:41:13.486 PST [107444] LOG:  redirecting log output to
logging collector process
2022-10-24 07:41:13.486 PST [107444] HINT:  Future log output will appear
in directory "log".
 stopped waiting
pg_ctl: could not start server
Examine the log output.

Thanks,

Chris Albert Navarroza
Information Technology Officer I
CTCO - ITDS - RDMD


On Mon, Oct 24, 2022 at 8:12 AM Tom Lane  wrote:

> chris navarroza  writes:
> > could not connect to source postmaster started with the command:
> > "/usr/pgsql-12/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D
> > "/home/dmartuser/pgdata/data" -o "-p 50432 -b -c
> > config_file=/var/lib/pgsql/12/data/postgresql.conf -c listen_addresses=''
> > -c unix_socket_permissions=0700 -c unix_socket_directories='/tmp'" start
> > Failure, exiting
>
> Did you look into the postmaster log (pg_upgrade_server.log, here)
> to see what it thought about the problem?  I'm guessing there's
> something that kept it from starting, but there's no evidence
> offered here about what.
>
> regards, tom lane
>


Re: Upgrading error

2022-10-24 Thread chris navarroza
Hi,

Thanks for the reply!

Sorry I missed that line, but now I'm having new error.

[root@datamartds tmp]# sudo su postgres
bash-4.4$ cd /tmp
bash-4.4$ /usr/pgsql-14/bin/pg_upgrade
--old-datadir=/home/dmartuser/pgdata/data/
--new-datadir=/home/dmartuser/pgsql/14/data/
--old-bindir=/usr/pgsql-12/bin/ --new-bindir=/usr/pgsql-14/bin/
--old-options '-c config_file=/var/lib/pgsql/12/data/postgresql.conf'
--new-options '-c config_file=/var/lib/pgsql/14/data/postgresql.conf'
--check
Performing Consistency Checks
-
Checking cluster versions   ok

*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.

connection to server on socket "/tmp/.s.PGSQL.50432" failed: No such file
or directory
Is the server running locally and accepting connections on that
socket?

could not connect to source postmaster started with the command:
"/usr/pgsql-12/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D
"/home/dmartuser/pgdata/data" -o "-p 50432 -b -c
config_file=/var/lib/pgsql/12/data/postgresql.conf -c listen_addresses=''
-c unix_socket_permissions=0700 -c unix_socket_directories='/tmp'" start
Failure, exiting



Thanks,

Chris Albert Navarroza
Information Technology Officer I
CTCO - ITDS - RDMD


On Fri, Oct 21, 2022 at 10:08 PM Tom Lane  wrote:

> chris navarroza  writes:
> > bash-4.4$ /usr/pgsql-14/bin/pg_upgrade
> > --old-datadir=/home/dmartuser/pgdata/data/
> > --new-datadir=/home/dmartuser/pgdata/data/
> --old-bindir=/usr/pgsql-12/bin/
> > --new-bindir=/usr/pgsql-14/bin/ --check --verbose
> > Running in verbose mode
> > Performing Consistency Checks
> > -
> > Checking cluster versions
> > This utility can only upgrade to PostgreSQL version 14.
>
> You cannot use the same directory as --old-datadir and --new-datadir.
> I think pg_upgrade is unhappy because what it sees in PG_VERSION in
> the --new-datadir isn't v14 ... but I wonder if we shouldn't be
> checking for this mistake more directly.
>
> Anyway, the right way to proceed is to use v14's initdb to create
> a new directory at, say, /home/dmartuser/pgdata/data-14
> and then pg_upgrade to that.  Afterwards you can rename the old
> data directory out of the way and move the new one to
> /home/dmartuser/pgdata/data, if you like.
>
> regards, tom lane
>