Weird query execution performanceSampling and matching samples with spatial conditionsCan't get Dell PE T420...

C++ range based loop with special case for first item?

Crack the bank account's password!

Is the tritone (A4 / d5) still banned in Roman Catholic music?

Are all power cords made equal?

How to transport 10,000 terrestrial trolls across ocean fast?

bash aliases do not expand even with shopt expand_aliases

Is there any danger of my neighbor having my wife's signature?

Canadian Visa by land

Disk space full during insert, what happens?

Expression for "unconsciously using words (or accents) used by a person you often talk with or listen to"?

How bad is a Computer Science course that doesn't teach Design Patterns?

What is the Buddhist view in Socratic questioning?

Identify non-coding regions from a genome annotation

Why can all solutions to the simple harmonic motion equation be written in terms of sines and cosines?

Converting numbers to words - Python

What is this mysterious *green square* on my Content Editor?

Can an attached stirge deal no more than 10 HP of damage before it detaches?

How to make transparent background from pdf to png

How can changes in personality/values of a person who turned into a vampire be explained?

Including proofs of known theorems in master's thesis

How can I prep for the Curse of Strahd adventure effectively?

Is there any way to play D&D without a DM?

Graphical modeler calculator missing in QGIS3

Sed-Grep-Awk operations



Weird query execution performance


Sampling and matching samples with spatial conditionsCan't get Dell PE T420 (Perc H710) perform better than a MacMini with PostgreSQLBad performance with select on view if check for 'is null'Postgres query optimization: why could two very similar join tables have vastly different querying times?Optimise a LATERAL JOIN query on a big tableWhich index shall I create in Postgres to speedup join of two big (several million rows) tables connected one-to-many?Slow postgres query that uses quick sort instead of hash-aggregateVery slow simple JOIN querySlow query times for similarity searches with pg_trgm indicesDoes a view use a partition in PostgreSql?













0















I have a logical replication in two distinct databases in different machines. A query in one of those executes in 13 seconds, the same in another takes more than 13 minutes to finish.



The two machines have the same tables, indices, postgres version (10.6),
postgres conf, OS version and similar hardware configuration.



Execution plan:



Fast: https://explain.depesz.com/s/12rd



Slow: https://explain.depesz.com/s/v7ep



These are the indexes:



create index on tmp(cpf_cnpj);
create index on cliente_telefone(cpf_cnpj);
create index on cliente_telefone(id_telefone,cpf_cnpj);
create index on telefone(id_telefone);


create index on telefone(ddd, numero);



And this is the query:



    select b.cpf_cnpj, 
b.ddd,
b.numero,
'bom' as id_resultado
from tmp as b
left join cliente_telefone as ct on ct.cpf_cnpj = b.cpf_cnpj
inner join telefone as t on t.ddd = b.ddd and t.numero = b.numero
where
b.status in ('BESTFONE', 'Bom') and
ct.id_telefone is null;


I have already made vacuum full, reindex, set some settings like random page cost, disable and enable seqscan, disable and enable indexscan, nothing solved the problem.










share|improve this question























  • You you show us the plans generated using explain (analyze, buffers)?

    – a_horse_with_no_name
    8 mins ago
















0















I have a logical replication in two distinct databases in different machines. A query in one of those executes in 13 seconds, the same in another takes more than 13 minutes to finish.



The two machines have the same tables, indices, postgres version (10.6),
postgres conf, OS version and similar hardware configuration.



Execution plan:



Fast: https://explain.depesz.com/s/12rd



Slow: https://explain.depesz.com/s/v7ep



These are the indexes:



create index on tmp(cpf_cnpj);
create index on cliente_telefone(cpf_cnpj);
create index on cliente_telefone(id_telefone,cpf_cnpj);
create index on telefone(id_telefone);


create index on telefone(ddd, numero);



And this is the query:



    select b.cpf_cnpj, 
b.ddd,
b.numero,
'bom' as id_resultado
from tmp as b
left join cliente_telefone as ct on ct.cpf_cnpj = b.cpf_cnpj
inner join telefone as t on t.ddd = b.ddd and t.numero = b.numero
where
b.status in ('BESTFONE', 'Bom') and
ct.id_telefone is null;


I have already made vacuum full, reindex, set some settings like random page cost, disable and enable seqscan, disable and enable indexscan, nothing solved the problem.










share|improve this question























  • You you show us the plans generated using explain (analyze, buffers)?

    – a_horse_with_no_name
    8 mins ago














0












0








0








I have a logical replication in two distinct databases in different machines. A query in one of those executes in 13 seconds, the same in another takes more than 13 minutes to finish.



The two machines have the same tables, indices, postgres version (10.6),
postgres conf, OS version and similar hardware configuration.



Execution plan:



Fast: https://explain.depesz.com/s/12rd



Slow: https://explain.depesz.com/s/v7ep



These are the indexes:



create index on tmp(cpf_cnpj);
create index on cliente_telefone(cpf_cnpj);
create index on cliente_telefone(id_telefone,cpf_cnpj);
create index on telefone(id_telefone);


create index on telefone(ddd, numero);



And this is the query:



    select b.cpf_cnpj, 
b.ddd,
b.numero,
'bom' as id_resultado
from tmp as b
left join cliente_telefone as ct on ct.cpf_cnpj = b.cpf_cnpj
inner join telefone as t on t.ddd = b.ddd and t.numero = b.numero
where
b.status in ('BESTFONE', 'Bom') and
ct.id_telefone is null;


I have already made vacuum full, reindex, set some settings like random page cost, disable and enable seqscan, disable and enable indexscan, nothing solved the problem.










share|improve this question














I have a logical replication in two distinct databases in different machines. A query in one of those executes in 13 seconds, the same in another takes more than 13 minutes to finish.



The two machines have the same tables, indices, postgres version (10.6),
postgres conf, OS version and similar hardware configuration.



Execution plan:



Fast: https://explain.depesz.com/s/12rd



Slow: https://explain.depesz.com/s/v7ep



These are the indexes:



create index on tmp(cpf_cnpj);
create index on cliente_telefone(cpf_cnpj);
create index on cliente_telefone(id_telefone,cpf_cnpj);
create index on telefone(id_telefone);


create index on telefone(ddd, numero);



And this is the query:



    select b.cpf_cnpj, 
b.ddd,
b.numero,
'bom' as id_resultado
from tmp as b
left join cliente_telefone as ct on ct.cpf_cnpj = b.cpf_cnpj
inner join telefone as t on t.ddd = b.ddd and t.numero = b.numero
where
b.status in ('BESTFONE', 'Bom') and
ct.id_telefone is null;


I have already made vacuum full, reindex, set some settings like random page cost, disable and enable seqscan, disable and enable indexscan, nothing solved the problem.







postgresql postgresql-10






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 10 mins ago









Gabriel NothGabriel Noth

1




1













  • You you show us the plans generated using explain (analyze, buffers)?

    – a_horse_with_no_name
    8 mins ago



















  • You you show us the plans generated using explain (analyze, buffers)?

    – a_horse_with_no_name
    8 mins ago

















You you show us the plans generated using explain (analyze, buffers)?

– a_horse_with_no_name
8 mins ago





You you show us the plans generated using explain (analyze, buffers)?

– a_horse_with_no_name
8 mins ago










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f230528%2fweird-query-execution-performance%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Database Administrators Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f230528%2fweird-query-execution-performance%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...