My listing is taking too long to load

Asked

Viewed 47 times

1

<div class="table-responsive">
    <table class="table table-striped">
        <thead>
            <tr>
                <th class="text-center">ID</th>
                <th>Nome</th>
                <th>Cpf</th>
                <th>Estado</th>
                <th>Cidade</th>
                <th>Filho Data Nascimento</th>
                <th>Categoria</th>
                <th>Cadastro</th>
                <th>Usuário</th>
                <th class="text-center">Ações</th>
            </tr>
        </thead>
        <tbody>

            $mysql = new mysqli("localhost", "root", "", "dbax");

            $query = $mysql->query("SELECT * FROM c_endereco INNER JOIN c_cliente ON c_cliente.idunico_cliente = c_endereco.idunico_cliente INNER JOIN c_cadastro ON c_cadastro.idunico_cliente = c_endereco.idunico_cliente INNER JOIN c_entrevista ON c_entrevista.idunico_cliente = c_endereco.idunico_cliente INNER JOIN c_finalizou ON c_finalizou.idunico_cliente = c_endereco.idunico_cliente ORDER BY c_cliente.ID DESC LIMIT 10;");        
            while($row = $query->fetch_array()){            
            $c_link = "http://localhost/painel/redireciona.php?id=".$row['idunico_cliente']."&cep=".$row['cliente_cep'];

            <tr>
                <td class="text-center" style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['ID']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_nome']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_cpf']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_estado']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_cidade']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_filho_nascimento']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_categoria']; ?></td> 
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php echo $row['cliente_cadastro_data']; ?></td>
                <td style="cursor: pointer;" onclick="window.open('<?php echo $c_link; ?>');"><?php if (!empty($row['cliente_user_resp'])) {  ?><small style="color:red" ><?php echo $row['cliente_user_resp']; ?></small><?php }else{ ?><small style="color:green" >Disponivel</small><?php } ?></td>

                <td class="td-actions text-right">
                    <button type="button" rel="tooltip" class="btn btn-info btn-just-icon btn-sm">
                        <i class="material-icons">person</i>
                    </button>
                </td>
            </tr>
        }

    </tbody>
</table>
</div>

Use to create a list with table, when it goes from 1000 ~ 3000 entries in the database it takes to load even drops, even putting LIMIT what I can do to solve it?

  • João, paste all your code, because the problem may be in the structure before or after the bank consultation.

  • Okay I’ll change now

  • Okay, this is a system for an internal panel, I plan to switch to PDO soon but for now I just need it to work well

  • Apparently your script is very basic, so there is no apparent problem. If you run the query directly in the database, is it slow ? Test run the query remotely, directly in the database locally, etc, so you can find where the problem might be, since in your script almost sure it is not. As for the PDO, search well the real need for this, because it is in parts slower because it uses more steps, and usually nobody uses multiple banks.

  • So I would use PDO to improve the work but in a matter of security or need would not need to be an internal system without public access

  • I removed the Inner Join and it is loading normal! But can not use without Inner Join, only if you have another way to select several tables

  • You need to go by parts. First, test straight into the database on the local machine. If you don’t slow down, test on another one with direct access to the bank, remotely. If you don’t, test your script on another machine. This may be a problem in your database, php, etc (try to restart database services, apache, etc)

  • I tested in 3 different locations, LINUX cloud server, my computer, and default hosting, all the same poblema!

  • Have phpmyadmin on the server ? Tested from it ?

  • Has yes, phpmyadmin ta normal, and something else when I do only 1 Inner Join without while it loads normal!

  • It’s probably slow in the php service, because if it’s normal in the database, I’d focus on that.

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.