Re: Query much slower from php than psql or dbeaver

2022-01-20 Thread Ekaterina Amez
El vie, 21 ene 2022 a las 5:04, Michael Lewis () escribió: > When dealing with foreign tables, I believe planning is not the same > because of access to statistics (maybe has improved since 9.6 though). I > just wonder... Would it be a viable option to create a materialized view > using the FDW

Re: Query much slower from php than psql or dbeaver

2022-01-20 Thread Michael Lewis
When dealing with foreign tables, I believe planning is not the same because of access to statistics (maybe has improved since 9.6 though). I just wonder... Would it be a viable option to create a materialized view using the FDW but then use the PHP script against the local tables only?

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 4:34 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Thu, Jan 20, 2022 at 4:32 PM Ken Tanzer wrote: > >> >> >> On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston < >> david.g.johns...@gmail.com> wrote: >> >>> You can always write: >>> >>> CREATE VIEW

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 4:32 PM Ken Tanzer wrote: > > > On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> You can always write: >> >> CREATE VIEW cte_view AS >> WITH cte AS (...) >> SELECT * FROM cte; >> >> And then incorporate that into any queries

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Ken Tanzer
On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston < david.g.johns...@gmail.com> wrote: > You can always write: > > CREATE VIEW cte_view AS > WITH cte AS (...) > SELECT * FROM cte; > > And then incorporate that into any queries that require the results of > said CTE. > > Is there any advantage to

Re: psql does not provide proper response

2022-01-20 Thread Adrian Klaver
On 1/20/22 12:35, Shaozhong SHI wrote: Added.  But only head of columns appeared. Best guess is there is no data in table. Do: select count(*) from boundaryline.scotland_and_wales_const_region; Any way to visualise? Regards, David On Thursday, 20 January 2022, Rob Sargent

Re: psql does not provide proper response

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 1:35 PM Shaozhong SHI wrote: > Added. But only head of columns appeared. Then the table is probably empty... Any way to visualise? > Visualize what? You do realize that psql is a text-based application, right? David J.

Re: psql does not provide proper response

2022-01-20 Thread Shaozhong SHI
Added. But only head of columns appeared. Any way to visualise? Regards, David On Thursday, 20 January 2022, Rob Sargent wrote: > On 1/20/22 10:54, Shaozhong SHI wrote: > > I do not know what happened. > > psql does not provide proper response anymore. > > I typed the following and see

Re: psql does not provide proper response

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 10:55 AM Shaozhong SHI wrote: > I do not know what happened. > > psql does not provide proper response anymore. > > I typed the following and see nothing. > > user=# select * from boundaryline.scotland_and_wales_const_region > user-# > > Can anyone enlighten me? > > You

Re: psql does not provide proper response

2022-01-20 Thread Pavel Stehule
čt 20. 1. 2022 v 19:50 odesílatel Bryn Llewellyn napsal: > > shishaozh...@gmail.com wrote: > > > > I do not know what happened. > > > > psql does not provide proper response anymore. > > > > I typed the following and see nothing. > > > > user=# select * from

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 11:36 AM Garfield Lewis wrote: > The following knows there is no CTID so shouldn’t I be able to get > something similar programmatically? > > [sysprog@nucky lz_pgmod] (h-master-LZRDB-4714)*$ psql -U postgres -d > postgres -c "select ctid, 'test'" > ERROR: column "ctid"

Re: psql does not provide proper response

2022-01-20 Thread Bryn Llewellyn
> shishaozh...@gmail.com wrote: > > I do not know what happened. > > psql does not provide proper response anymore. > > I typed the following and see nothing. > > user=# select * from boundaryline.scotland_and_wales_const_region > user-# > > Can anyone enlighten me? This happens to me all

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread Garfield Lewis
On 2022-01-20, 1:11 PM, "Tom Lane" wrote: >No, it's the same problem in reverse: the output function cannot >know where the value came from. There is no hard and fast >reason that it must have come out of a table, either. Consider >something as simple as > > SELECT 'blah

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread Tom Lane
Garfield Lewis writes: > I think you are right in the case of INPUT/RECEIVE, however we should be able > to get that info during OUTPUT/SEND (I think) since it is fixed at that > point. At the time I return the information to the user I could augment the > output to add that information to the

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread Garfield Lewis
> On 2022-01-20, 12:52 PM, "Tom Lane" wrote: > >Garfield Lewis writes: >> I need the page and possibly row of the data location to be stored as an > element of the new type. This is to simulate a structure from another > database system. > >You need to rethink. The datatype input

Re: Query much slower from php than psql or dbeaver

2022-01-20 Thread Tom Lane
Ekaterina Amez writes: > I've tested the query with psql and DBeaver and it takes only milliseconds: > it returns 39 records and now there's only 16000 records on the table but > I've tested it with <100K. When I've tested my php script the same query > takes 14 minutes to return (more or less).

Re: psql does not provide proper response

2022-01-20 Thread Rob Sargent
On 1/20/22 10:54, Shaozhong SHI wrote: I do not know what happened. psql does not provide proper response anymore. I typed the following and see nothing. user=# select * from boundaryline.scotland_and_wales_const_region user-# Can anyone enlighten me? Regards, David Add semi-colon return?

psql does not provide proper response

2022-01-20 Thread Shaozhong SHI
I do not know what happened. psql does not provide proper response anymore. I typed the following and see nothing. user=# select * from boundaryline.scotland_and_wales_const_region user-# Can anyone enlighten me? Regards, David

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread Tom Lane
Garfield Lewis writes: > I need the page and possibly row of the data location to be stored as an > element of the new type. This is to simulate a structure from another > database system. You need to rethink. The datatype input function cannot know even that the value is going to be stored

Re: Query on postgres_fdw extension

2022-01-20 Thread Vijaykumar Jain
On Thu, 20 Jan 2022 at 21:29, Duarte Carreira wrote: > Hello everyone. > > I don't know... realistically what do you guys see as a best/simple > approach? > We implemented a custom sharding (directory sharding with lookup tables) layer of 10 shards, but it was write local, read global. the api

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread Garfield Lewis
A CTID is a special column documented here: https://www.postgresql.org/docs/12/ddl-system-columns.html Regards, Garfield

Re: [EXT] Re: Can we get the CTID value

2022-01-20 Thread Garfield Lewis
Hi Laurenz, I need the page and possibly row of the data location to be stored as an element of the new type. This is to simulate a structure from another database system. Regards, Garfield

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 7:42 AM Avi Weinberg wrote: > > > Thanks David for the reply, but my question was a little different. > > I know I can have multiple CTE queries like you showed, but I want to > have one single WITH query, and use it in multiple queries, not just by one > query the

Re: Query on postgres_fdw extension

2022-01-20 Thread Duarte Carreira
Hello everyone. I got here after encountering the same difficulty, although on a much more mundane scenario. I'm used to fdw on a read-only basis. I was just inserting a new record on a foreign table and got blocked... and after much searching got here. Not to rant or anything, but I am

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Johannes Graën
On 20/01/2022 15.42, Avi Weinberg wrote: Thanks David for the reply, but my question was a little different. I know I can have multiple CTE queries like you showed, but I want to have one single WITH query, and use it in multiple queries, not just by one query the directly proceed the CTE.

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Josef Šimánek
čt 20. 1. 2022 v 13:48 odesílatel Avi Weinberg napsal: > > Hi, Hello! > > > Can I have multiple select statements using one WITH statement? > > > > WITH t AS ( > > Select A, B from … > > ) > > SELECT A into tableA FROM t where ….; > > > > SELECT B into tableB FROM t where ….; > I think it is

RE: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Avi Weinberg
Thanks David for the reply, but my question was a little different. I know I can have multiple CTE queries like you showed, but I want to have one single WITH query, and use it in multiple queries, not just by one query the directly proceed the CTE. Why do I need to execute the CTE query twice

Query much slower from php than psql or dbeaver

2022-01-20 Thread Ekaterina Amez
Hi, After receiving an Unknown Address error with *pgsql-...@postgresql.org* I've discovered this mailing list is catalogued as Inactive, so I'm sending my question to this list. I've made a php cli script that downloads a file from FTP, loads it in a table and compares against the same table in

Re: Cannot find hstore operator

2022-01-20 Thread Tom Lane
Paul van der Linden writes: > during maintenance I saw a lot of lines in my postgreslog saying: > CONTEXT: SQL function "line_function" during inlining > automatic analyze of table "osm.planet_osm_line" > ERROR: operator does not exist: public.hstore -> unknown at character 45 It

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thursday, January 20, 2022, Avi Weinberg wrote: > Hi, > > > > Can I have multiple select statements using one WITH statement? > > > > WITH t AS ( > > Select A, B from … > > ) > > SELECT A into tableA FROM t where ….; > > > > SELECT B into tableB FROM t where ….; > > > With q1 as (), q2 as

Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Avi Weinberg
Hi, Can I have multiple select statements using one WITH statement? WITH t AS ( Select A, B from ... ) SELECT A into tableA FROM t where ; SELECT B into tableB FROM t where ; IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain

Re: Can we get the CTID value

2022-01-20 Thread o1bigtenor
On Wed, Jan 19, 2022 at 1:39 PM Garfield Lewis wrote: > > Hi, > > > > I am creating a new type and would like to know if it was possible to access > the CTID for the row affected by the INPUT and RECEIVE functions of the new > type? Actually, would it be possible from the OUTPUT and SEND

Cannot find hstore operator

2022-01-20 Thread Paul van der Linden
Hi, during maintenance I saw a lot of lines in my postgreslog saying: CONTEXT: SQL function "line_function" during inlining automatic analyze of table "osm.planet_osm_line" ERROR: operator does not exist: public.hstore -> unknown at character 45 HINT: No operator matches the given name

Re: Can we get the CTID value

2022-01-20 Thread Laurenz Albe
On Wed, 2022-01-19 at 19:38 +, Garfield Lewis wrote: > I am creating a new type and would like to know if it was possible to access > the CTID for the row affected by the INPUT and RECEIVE functions of the new > type? > Actually, would it be possible from the OUTPUT and SEND functions as