pg_sql | Unsorted

Telegram-канал pg_sql - PostgreSQL

2830

English speaking PostgreSQL public chat. This group is for discussions on PostgreSQL-related topics and strives to provide best-effort support as well.

Subscribe to a channel

PostgreSQL

Could you share the query or a solid explain plan.
You mentioned calling a function. I've seen PG do some crazy stuff when functions (or what it sees as lateral joins) are needed.
A trick I have used a few times is :
WITH qry AS MATERIALIZED ( Select FUNCTION(),id from security_table)
SELECT ... and join in the materialized query. the upside is it only runs the selects ONCE from whatever table. Otherwise, I've seen it call it for EVERY ROW in the FILTER as it does a SEQ Scan.

But sharing the query would make it a lot easier to comment.
Also, sometimes I will break normalization and store something twice, or use a functional index that pre-parses what I am looking for.

Читать полностью…

PostgreSQL

Has anyone seen that pgbackrest started filling the root file system while the backup destination is AWS S3 due to any issue ?

Читать полностью…

PostgreSQL

Your startup log on the former primary _should_ tell you if it did restore any WAL segments before the missing one or if it fails straight away.
A more common problem would be a split brain situation.
My recommendation would be to make a (delta) backup and (delta) restore that. If you lost some WAL, you want a proper backup anyway...

Читать полностью…

PostgreSQL

Rsync to only transfer back the changed data

Читать полностью…

PostgreSQL

Hi all, I have 2 postgresql node patroni cluster, something went wrong before 4 hrs on primary and failover has happened. Now the previous primary is in stopped state, and after monitoring for few times as automatic pg_rewind was running status changes to starting but not coming up because when I see the postgresql logs it says some wal_file file is missing, now I have one option to reinit the cluster but will take lot of time as db size is 3TB , any other approach you suggest????

Читать полностью…

PostgreSQL

Yes. Not informative.

Читать полностью…

PostgreSQL

Why, you came to this conclusion ourselves - to use long names

Читать полностью…

PostgreSQL

You right. So you need using long names for PK fields in tables. Else it will be strange

CREATE TABLE bar
(
bar_id bigserial not null primary key,
id bigint not null references foo (id)
);

Читать полностью…

PostgreSQL

Oh, correct. But in practice we are rarely join two table with their PK. We usually use the FK and PK, right?

Читать полностью…

PostgreSQL

I means name the primary key with the table name prefix. Such as:

CREATE TABLE foo(
foo_id bigserial not null primary key
)

Читать полностью…

PostgreSQL

cannot, the USING can only used when the field in the two tables has the same name. ON t1.name = t2.name

Читать полностью…

PostgreSQL

I prefer the shorter one in the past, but recently, I'm more prefer to use the USING keyword in JOIN clause. In that cases, the longer one is easier to use... I feel difficult to make the decision...

Читать полностью…

PostgreSQL

I was just surprised by how much of a difference DNS can make. Switching to a dedicated DNS provider cut 120ms off of our page load time.

Читать полностью…

PostgreSQL

Cashed DNS resolver, seems likely then right¿

Читать полностью…

PostgreSQL

You mean that it took a bit to propagate the certs, and cash the lookup both in my own local DNS resolver and VPS DNS resolver?

Читать полностью…

PostgreSQL

du -cms * | sort -n is your friend... Some logs, I guess?

Читать полностью…

PostgreSQL

Thankyou, let me check the delta backup and restore

Читать полностью…

PostgreSQL

I have backup running via pgbackrest and destination is s3 so wals I can take from there but how many exactly needed as in 4 hrs there would have been multiple files

Читать полностью…

PostgreSQL

So you don't have a WAL archive?

Читать полностью…

PostgreSQL

That's a bit like "do you prefer red or blue". Both ways work well enough, as long as you don't mix them [in your team].
I personally prefer to name FKs like fk_customerid or even fk_customer. And customer.id to me feels more natural than customer.customer_id 🤷

Читать полностью…

PostgreSQL

Because as you said, it's more strange and a bit ugly.

Читать полностью…

PostgreSQL

🥲🥲🥲 I feel difficult to make the decision...

Читать полностью…

PostgreSQL

Such as we have two table

CREATE TABLE foo
(
foo_id bigserial not null primary key
);
CREATE TABLE bar
(
bar_id bigserial not null primary key,
foo_id bigint not null references foo (foo_id)
);

SELECT * FROM foo INNER JOIN bar b USING (foo_id);

Читать полностью…

PostgreSQL

Well, but if you will create another table with longer name of PK column

CREATE TABLE bar(
bar_id bigserial not null primary key
)

You cant use USING in joining tables foo and bar.

As you say:
cannot, the USING can only used when the field in the two tables has the same name. ON t1.name = t2.name

Читать полностью…

PostgreSQL

But how name of primary key depends of name of columns?

Читать полностью…

PostgreSQL

Are there two tables (t1, t2) with columns with different names (t1.t1_id, t2.t2_id) can be joined by USING?

Читать полностью…

PostgreSQL

Hello friends, I want to know what do you think of the name of the primary key. id vs tablename_id ? Which one do you think better?

Читать полностью…

PostgreSQL

Not impossible.

Also DNS autoconfiguration problems.

Also hostname written to hosts or other database lately.

Читать полностью…

PostgreSQL

Certs don't propagate via DNS (usually).

Читать полностью…

PostgreSQL

In fact, most probably that was s dns issue.

Читать полностью…
Subscribe to a channel