Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8672837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:18:08+00:00 2026-06-12T19:18:08+00:00

I have a file that will be called via CRON for 30 to 30

  • 0

I have a file that will be called via CRON for 30 to 30 minutes, but would like some tips to improve it, because the way he is is VERY slow.

His logic is simple:

  1. Search the database all records with status not ready

  2. If records exist, it does a foreach, and for each instance of this class it calls another class to do a curl to grab an xml transforms it into md5 hash and compares the hash with the current database.

  3. If the hashes are different it does other things

The problem is that this process is very slow, if someone can improve this?

<?php

require_once($_SERVER['DOCUMENT_ROOT'] . 'setup.php');

$MySQL = new MySQL();
$resultados = $MySQL->query("SELECT * FROM objetos WHERE situacao != 'entregue' AND email = 1")->fetchAll(PDO::FETCH_ASSOC);

if ($resultados) {
    foreach ($resultados as $resultado) {
        $Rastreio = new Correios(new cURL(), $resultado['cod_objeto']);

        if ($Rastreio->resultado['hash'] != $resultado['hash']) {

            $user = $MySQL->query("SELECT  nome, email FROM usuarios WHERE id_usuario = {$resultado['fk_id_usuario']}")->fetch(PDO::FETCH_LAZY);

        // Doing something different

            $MySQL->exec("UPDATE objetos SET situacao = $Rastreio->resultado['status'], hash = {$Rastreio->$resultado['hash']} WHERE cod_objeto = {$resultado['cod_objeto']} AND fk_id_usuario = {$resultado['fk_id_usuario']}");
        }
    }
    } 

All answers were useful. I think the problem is in the database, my queries are not optimized as well. I’ll try what you told ….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:18:09+00:00Added an answer on June 12, 2026 at 7:18 pm

    This is not a complete answer, but I can’t comment, so it will have to be here.

    Some optimizations can be achieved:

    • Do you really need SELECT *? Can’t it be more specific for the fields that you need?
    • Is the condition AND email = 1 really needed?
    • Are you reusing the cURL session or creating a new one for each request?
    • You can unset rows from $resultados after each iteration so the set is smaller.
      The gain may be small, but still may help.
    • Are you retrieving unnecessary things in your cURL request?
      Like headers if you don’t need them.
    • If you are logging the cURL errors, do you have access to the file?
      Are you appending or rewriting?

    There may be other things to consider, but these questions should be the first things to check.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a php file that will run an event after five minutes have
i have done a code that will download the file from internet. but the
I have a file that users will purchase via paypal, clickbank and paydotcom. I
I have a batch file that will detect if the user has the .Net
I have a python file that will not correctly perform an import. If I
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
I have an image file that has all the character sprites that I will
I have been looking into libraries for a file system that will allow path
I have a text data file that I likely will read with readLines .
I have a script that will convert a text file into a resource file,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.