• Resolved Scott Farrell

    (@sfarrell5123)


    this sql is pretty slow on large databases,

    as I create more invoice with your code, most of the execution time becomes waiting for the calc of max invoice number

    perhaps saving it in the options table might be smarter.

    SELECT MAX(CAST(pm2.meta_value AS UNSIGNED)) AS last_invoice_number FROM wp_postmeta pm1 INNER JOIN wp_postmeta pm2 ON pm1.post_id = pm2.post_id WHERE pm2.meta_key =’_bewpi_invoice_number’;

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Scott Farrell

    (@sfarrell5123)

    I used this instead – was way faster – almost all the mysql cpu time disappeared.

    $getmaxinv = get_option(“pdfmaxinvoice”,7067 );
    $getmaxinv++;
    update_option(“pdfmaxinvoice”,$getmaxinv,true);
    return $getmaxinv;

    7067 was my next invoice number from the old system

    Plugin Author Bas Elbers

    (@baaaaas)

    Thanks for letting me know.
    I’ve created a workitem and will improve the code when I find the time.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘max invoice number code is slow’ is closed to new replies.