Re: Why does the planner reduce the planned rows when filtering single values in an array

2023-04-22 Thread Isaiah Langford
Thank you Tom,

Every tool is a work in progress. Knowing it's just a fact of life for now is 
really helpful, I appreciate the response.

From: Tom Lane 
Sent: Saturday, April 22, 2023 12:43 AM
To: Isaiah Langford 
Cc: pgsql-general@lists.postgresql.org 
Subject: Re: Why does the planner reduce the planned rows when filtering single 
values in an array

Isaiah Langford  writes:
> Why is the planner expecting the number of rows to be reduced by the join 
> filter? Is there any way I can correct the planner here?

I think you're running into a couple of issues here:

* ANALYZE fails to record any useful stats for a single-row table.
It can't form a histogram with only one entry, but it also fails to
put the value into the MCV list, because there's a heuristic that an
MCV must appear more than once.  Possibly we could think harder
about what to do with such cases, but at the moment the planner has
no knowledge that the only value in single_value_table is "1".

* Even if it did know that, the logic in scalararraysel() is quite
inadequate for the case of "variable = ANY(variable)".  It looks
like that's only been fleshed out for cases where one side or
the other is a constant.

Lot of unfinished work here :-(

regards, tom lane


Re: FW: Error!

2023-04-22 Thread Adrian Klaver

On 4/22/23 07:31, Arquimedes Aguirre wrote:

Hi Dear Good Morning!




Please do not top post. Either bottom or inline post per:

https://en.wikipedia.org/wiki/Posting_style



How to know if I have connection or not connection? May you explain for 
more details? please.


From the screenshot you have two Postgres servers active, PostgreSQL 15 
and punta. In the punta server you have two databases django-active and 
postgres. FYI, you don't want to add tables to the postgres database. 
It's primary purpose is to be a database you can connect to in the 
absence of other databases. The screenshot also shows you are connected 
to the databases. If you were not there would be a red x on the icon 
next to the database name. To get down to the tables you will need to 
click on Schemas and then Public. There will a series of items below 
that including Tables. Click on that and pick the table you want to work 
with. All of this is spelled out in more detail here:


https://www.pgadmin.org/docs/pgadmin4/6.21/index.html

Also you probably also look at the Properties for the PostgreSQL 15 
server shown in the screenshot to see what host and port it is running on.




I attach a screen what I did…

Thanks for his attention and collaboration!


 >



--
Adrian Klaver
adrian.kla...@aklaver.com





Re: How to verify postrgresql download on windows?

2023-04-22 Thread Ali M.
I am just trying to revive this question, I am still hoping to get an
answer

how can we verify the postgresql download on windows ?

Thanks
Ali

On Wed, Feb 8, 2023 at 2:03 PM Ali M.  wrote:

> Hi the Postgresql binaries and installer are provided by EDB
> How can i verify the download
>
> Usually other projects provide a SHA256 hash list to verify the downloads
> EDB doesnt seem to provide that, so how else can i verify the download
>
> Thanks
> Ali
>


Re: How to verify postrgresql download on windows?

2023-04-22 Thread Matthias Apitz
> On Wed, Feb 8, 2023 at 2:03 PM Ali M.  wrote:
> 
> > Hi the Postgresql binaries and installer are provided by EDB
> > How can i verify the download
> >
> > Usually other projects provide a SHA256 hash list to verify the downloads
> > EDB doesnt seem to provide that, so how else can i verify the download

You can't. You should ask EDB for MD5 or SHA256. Or you should reject
those binaries.

matthias

-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

No euro for the war! Keinen Euro für den Krieg! ¡No un Euro por la guerra!




SCROLLABLE/UPDATABLE cursor question

2023-04-22 Thread Garfield Lewis
Hi All,

I’m not sure where to ask the question so I’ll start here. Does anyone know if 
Postgres has any plans to support statements like FETCH/MOVE in the non-forward 
direction for SCROLLABLE/UPDATABLE cursors?

--
Regards,
Garfield A. Lewis



Re: SCROLLABLE/UPDATABLE cursor question

2023-04-22 Thread Tom Lane
Garfield Lewis  writes:
> I’m not sure where to ask the question so I’ll start here. Does anyone know 
> if Postgres has any plans to support statements like FETCH/MOVE in the 
> non-forward direction for SCROLLABLE/UPDATABLE cursors?

Doesn't that work already?

regards, tom lane




Why not use the calloc to replace malloc?

2023-04-22 Thread Wen Yi
HI team,
I'm a newbie to the postgres.
When I learn the code of libpq, the achieve of PQmakeEmptyPGresult, cause my  
curiosity.

The old version code:

PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
{
  PGresult   *result;

  result = (PGresult *) malloc(sizeof(PGresult));
  if (!result)
return NULL;

  result->ntups = 0;
  result->numAttributes = 0;
  result->attDescs = NULL;
  result->tuples = NULL;
  result->tupArrSize = 0;
  result->numParameters = 0;
  result->paramDescs = NULL;
  result->resultStatus = status;
  result->cmdStatus[0] = '\0';
  result->binary = 0;
  result->events = NULL;
  result->nEvents = 0;
  result->errMsg = NULL;
  result->errFields = NULL;
  result->errQuery = NULL;
  result->null_field[0] = '\0';
  result->curBlock = NULL;
  result->curOffset = 0;
  result->spaceLeft = 0;
  result->memorySize = sizeof(PGresult);
  /*
.
  */
  return result;
}

My version:

PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
{
  PGresult   *result;

  result = (PGresult *) calloc(sizeof(PGresult));
  if (!result)
return NULL;

  result->memorySize = sizeof(PGresult);
  /*
.
  */
  return result;
}

Why not have a change?I don't know.
I'm a newbie, so I don't think I can commit a patch for postgres, just instead 
of send mail to ask.

Yours,
Wenyi.


Re: Why not use the calloc to replace malloc?

2023-04-22 Thread Tom Lane
Wen Yi  writes:
> [ use calloc to replace zeroing fields individually ]

The reason we like to do it like that is that it provides greppability,
that is you can search the source code to see where a particular field
is initialized or modified.  The backend code is often intentionally
inefficient in this way: you can find a lot of places that do
makeNode(some-node-type) and then zero out fields within the node, even
though makeNode() always provides a zeroed-out struct.  An important
reason why this is a good idea is that the code isn't dependent on
whether the particular value you need to initialize the field to
happens to be bitwise zeros or something else.

People have complained about this practice off-and-on, but no one has
provided any evidence that there's a significant performance cost.
The maintenance benefits are real though.

regards, tom lane