English speaking PostgreSQL public chat. This group is for discussions on PostgreSQL-related topics and strives to provide best-effort support as well.
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.
Has anyone seen that pgbackrest started filling the root file system while the backup destination is AWS S3 due to any issue ?
Читать полностью…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...
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????
Читать полностью…Why, you came to this conclusion ourselves - to use long names
Читать полностью…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)
);
Oh, correct. But in practice we are rarely join two table with their PK. We usually use the FK and PK, right?
Читать полностью…I means name the primary key with the table name prefix. Such as:
CREATE TABLE foo(Читать полностью…
foo_id bigserial not null primary key
)
cannot, the USING can only used when the field in the two tables has the same name. ON t1.name = t2.name
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...
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.
Читать полностью…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?
Читать полностью…du -cms * | sort -n
is your friend... Some logs, I guess?
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
Читать полностью…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
🤷
Because as you said, it's more strange and a bit ugly.
Читать полностью…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);
Well, but if you will create another table with longer name of PK column
CREATE TABLE bar(
bar_id bigserial not null primary key
)
USING
in joining tables foo and bar.cannot, the USING can only used when the field in the two tables has the same name. ON t1.name = t2.nameЧитать полностью…
But how name of primary key depends of name of columns?
Читать полностью…Are there two tables (t1, t2) with columns with different names (t1.t1_id, t2.t2_id) can be joined by USING
?
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?
Not impossible.
Also DNS autoconfiguration problems.
Also hostname written to hosts or other database lately.