• hemasusi

    (@hemasusi)


    Hi,

    We have one custom plugin page. That page file path is – wp-content\mu-plugins\custom_api_logs_list.php

    We wrote the coding to list all our API logs from database logs table and list in the table format – look here – https://prnt.sc/Swje1VdgkVDh

    This page file having code to get data from logs table with offset & limit. But facing the slow php error in php slow log – https://prnt.sc/91W0Y-nAtv8r
    and please see other errors also in the screenshot.
    Due to the error, the page is not loading, its taking long time and display timeout error ‘The application did not respond in time’.

    Here is some screenshot from coding –
    https://prnt.sc/WZhGktRewP3X
    https://prnt.sc/rtcaMBwU2ME4
    https://prnt.sc/OlaBSDQ6d7cX
    https://prnt.sc/LkGFGEf1ayvO

    1. If I try print_r or echo before get_var() query, everything is working, no slow in the page. But get_var only not working. All other remaining is working.
    2. I tried get_results() instead of get_var() but thats also triggered error & not loading

    Its happened in WP 6.0.2 only i think.. Bcz before in old version, we didn’t face this issue.

    Can anyone please help.

    • This topic was modified 2 years ago by hemasusi.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 19 total)
  • I have checked your screenshots and you have 16K records, maybe your query is not correctly optimized and that is what is generating the slow performance and timeout error.

    I suggest you to try to make a backup, and delete some records and check if problem persist, you should optimize.

    Thread Starter hemasusi

    (@hemasusi)

    Hi,

    Yes, 16K records in staging/test site. But i rewrite the query with where condition to get only leass number of records (for ex, only one month or one date logs) that’s also creates the slow log error and showing timeout error.

    are you using InnoDB as storage engine on log table?

    As I researched, in this case is best to use MyISAM, because it stores the row count and don’t have to count every time that you do a query like InnoDB does.

    Thread Starter hemasusi

    (@hemasusi)

    We are using MariaDB. And for your info, as you see in the screenshot we put limit and offset when fetch the data from log table.

    I mean the table, you can check in phpmyadmin, clic on the table and then go to operations, on the “table options” you can see what you are using:

    here is a screenshot of a table that uses InnoDB (it will not have good performance), can you try change it to MYISAM

    View post on imgur.com

    • This reply was modified 1 year, 12 months ago by Seba Ocano. Reason: wrong image link

    I think this COUNT(*) could be generating the slow performace:

    https://prnt.sc/rtcaMBwU2ME4

    Thread Starter hemasusi

    (@hemasusi)

    Hi,

    We can’t change the Innodb, its a server thing.
    I think this COUNT(*) could be generating the slow performace – I tried removing the count, just written the select * but it also create the slow log for get_var

    too bad you can not change to Innodb,

    just to be sure, can you return a number value instead of doing the count(*) here https://prnt.sc/rtcaMBwU2ME4 ?

    lets say 15000 and check, if it still not works well we can keep checkign the rest of the code.

    Thread Starter hemasusi

    (@hemasusi)

    Hi,

    I used get_results(select query), and gets the number value using num_rows.
    Even the same slow error for get_results as get_var.

    Mmm, I think I was not clear, I mean not query at all and just use an arbitrary value. If doing this works with good performance we will now that this query is causing the problems

    Thread Starter hemasusi

    (@hemasusi)

    Okay, i will try to set the static value for this record_count & let you know.

    Thread Starter hemasusi

    (@hemasusi)

    Hi,

    I tried to remove the record_count function and write default count for that variable. It removes the error, but showing another error for get_results()
    https://prnt.sc/6o-3rg9m3dtk
    https://prnt.sc/EYieP0c7ZmCX
    https://prnt.sc/xFt8LlwYZ0sS

    Mmm, there is no error detail, maybe you can check another log?

    if not, can you print the $sql variable and try to executed on phpmyadmin to receive a more detailed error?

    • This reply was modified 1 year, 12 months ago by Seba Ocano.
    Thread Starter hemasusi

    (@hemasusi)

    Hi,

    Yes i tried printing the $sql it gives a query. It fetching the data when i execute the same query in phpmyadmin/mysql. But the get_results only causing error and not giving the result..

    There is no detailed error file i think. I will check with the server team.

    Hi @hemasusi, what about enabling debug mode on the wp-config file ?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Custom Plugin (mu-plugins) Issue’ is closed to new replies.