Streamline SQL Query with Datatables

Asked

Viewed 105 times

0

The query below returns a DataTables with approximately 400 database items Mysql. The difficulty is to return these values faster. Currently it takes on average 70 seconds to fully display the list. It is a low number of items even so there is a great delay. There is possibility to improve performance through the SELECT?

SELECT 
   p.*,
   pc.*,
   u.name as autor, u.surname
FROM 
    `product` p
INNER JOIN
    `product_config` pc ON p.id = pc.id_product
LEFT JOIN
    `users` u ON u.id = p.idAutor
ORDER BY 
    p.id DESC 
  • 1

    Do you really need to select everything (*) in two tables? Are you sure the bottleneck is the query? If you run select 'from the outside' does it also take? How are the indexes in this table?

  • @Genos made the selection only of the useful fields in the Datatables assembly and didn’t really have much change in loading. One of the columns displayed the product image, I removed this information and the performance changed dramatically. I believe it has something to do with uploading images to Datatables, as it waits for all elements to be uploaded.

  • @Dagobe you came to use the plugin’s Processing server-side functionality?

  • @Cesar no. What I did was take an image of the product I was carrying in one of the columns.

No answers

Browser other questions tagged

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