MySQL Forums
Forum List  »  Stored Procedures

Re: Query times out when I add extra Where Condition
Posted by: Peter Brawley
Date: January 28, 2020 08:52AM

> how to tell how much of the 8G RAM is available to mysql ??

In Task Manager it's Mem free + MySQL RAM use assuming no other apps will use significant RAM while MySQL is running.

If MySQL refuses to run with innodb_buffer_pool_size > 2GB, MySQL probably has only about 3 of your 8GB to work with. You'll need to watch Task Manager's tracking of MySQL mem use while this query is running. Swapping during query execution needs to be zero.

The DDL shows no covering indexes. The big tables are salesledgers and receipts, so there'll be best improvements by starting with them. A first-order rule of thumb for covering indexes is WHERE columns first, then INNER JOIN columns, then left-sided LEFT JOIN columns, then SELECT list columns if there aren't too many (here there are). So I'd start with these covering indexes ...

salesledger: invoicedate,paidinfulldate,invnum
receipts: invoicedate,receiptdate,invnum

1 turn off the mysql query cache

2 extract one of the three unioned subqueries from the sproc, supply params as required, benchmark it

3 add a covering index

4 run Explain to ensure MySQL is using it

5 benchmark it again

Repeat with a different covering index till performance is reasonable.

Edited 1 time(s). Last edit at 01/29/2020 10:41AM by Peter Brawley.

Options: ReplyQuote

Written By
Re: Query times out when I add extra Where Condition
January 28, 2020 08:52AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.