Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
Why would a SQL query take significantly longer to run when the row return limit is increased by 1?

When running the following query:

SELECT customers.ID, customers.FNAME, customers.MNAME, customers.LNAME,
    customers.SUFFIX, addresses.ADDRESS, addresses.CITY, addresses.STATE, 
    addresses.ZIP 
from db_name.customers 
INNER JOIN db_name.addresses ON customers.ID=addresses.CID
limit 6607;

while connected to a MariaDB instance on AWS RDS from MySQL workbench, the query runs with the following metadata results:

6607 row(s) returned Duration: 0.507 sec / Fetch Time: 8.524 sec

Additionally, when the results are exported to a csv file, the size is about 466KB. However, when I run the same query with only changing the last line to retrieve one more row: limit 6608 The query does not finish (I killed it after nearly an hour).

Furthermore, I noticed that the Fetch Time experiences a big jump between limit 4000 and limit 4001 rows. Whether this insight useful or not, I have included a graph of fetch times (fetch time on the vertical axis) while varying the row limit (number of rows returned on the horizontal axis). I do not understand why fetch time appears to be a piecewise continuous (linear) function of rows returned:

Fetch time by row limit scatter plot enter image description here

If anyone has an idea about what is preventing me from returning more than 6607 rows, I would love your advice. Thank you!

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda