Looking at the my.ini
, I have two suggestions
SUGGESTION #1
I would bump up the following settings in your my.ini
sort_buffer_size=4M
join_buffer_size=4M
This will make some joins and sort stay in memory. Of course, once a JOIN
or an ORDER BY
needs more than 4M
, it will page to disk as a MyISAM table.
If you cannot login as root@localhost
, then restart mysql with
C:\> net stop mysql
C:\> net start mysql
If you can login as root@localhost, you do not have to restart mysql to use these settings.
Just run this in the MySQL client:
SET @FourMegs = 1024 * 1024 * 4;
SET GLOBAL sort_buffer_size = @FourMegs;
SET GLOBAL join_buffer_size = @FourMegs;
SUGGESTION #2
Since your Data is on Drive D:
, you may have Disk I/O on Drive C:
.
Please run this query:
mysql> show variables like 'tmpdir';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| tmpdir | C:\Windows\TEMP |
+---------------+-----------------+
1 row in set (0.00 sec)
Since I run mysql on my Desktop with defaults, my temp tables are being written to Drive C:
. If Drive D is a better disk than Drive C:
, perhaps you can map temp tables to Drive D:
by setting tmpdir in my.ini
as follows:
tmpdir="D:/DBs/"
You will have to restart mysql since tmpdir is not a dynamic variable.
Give it a Try !!!
UPDATE 2013-11-29 10:09 EST
SUGGESTION #3
Given the fact that MySQL is running in Windows and you cannot touch the queries in the core package, I have two ideas tat must be done together.
IDEA #1 : Move the Database to a Linux Machine
You should be able to
- Setup a Linux machine
- Install MySQL on the Linux machine
- Enable Binary Logging for MySQL in Windows
- mysqldump the database to a text SQL file
- Load SQL file to MySQL running in Linux
- Setup replication from MySQL/Windows to MySQL/Linux
IDEA #2 : Reconfigure Moodle to point to the Linux Machine
Moodle was designed for LAMP in the first place. Just change the config files to point to the Linux machine instead of localhost.
Here is a link to an old Moodle 2.3 doc on setting up MySQL : http://docs.moodle.org/23/en/Installing_Moodle#Create_an_empty_database
I am sure the latest docs are available as well.
What is the Point of Moving the Database to Linux ???
How does this help the temp table situation ???
I would then suggestion setting up a RAM disk as the target folder for your temp tables
Temp table creation will still happen, but it will be written to RAM rather than disk. reducing Disk I/O.
UPDATE 2013-11-29 11:24 EST
SUGGESTION #4
I would suggest revisiting SUGGESTION #2 with a fast RAID-0 disk (32+ GB), configuring it as Drive T: (T for Temp). After installing such a disk, add this to my.ini
:
[mysqld]
tmpdir="T:\"
MySQL restart would be required, using
net stop mysql
net start mysql
BTW I said RAID-0 on purpose so that you can get good write performance over a RAID-1, RAID-10. A tmp table disk is not something I would make redundant.
Without optimizing the queries as @RaymondNijland has been commenting on, you cannot reduce the temp table creation count in any way. SUGGESTION #3
and SUGGESTION #4
offer speeding up temp table creation and temp table I/O as the only alternative.
Generally, no. A few tangentially related things to note though:
You could use a symlink to move the /<datadir>/db2/
directory to another storage/block device. Or you could use the CREATE TABLE ... DATADIR=/../
option to move only the support_chat table to another storage/block device. That could make a big difference, assuming that you're frequently disk bound.
With MySQL 5.6, using multiple databases/schemas can help to improve slave throughput (assuming you're using replication) because the parallelization was at the schema level:
Replication Slave Options and Variables --slave-parallel-workers
So with three databases/schemas, you would benefit from setting slave-parallel-workers=3
.
For more info on the multi-threaded slave work in MySQL 5.6:
MySQL Replication High Performance: Multi-Threaded Slaves and
Group Commit (pdf)
Just FYI, the multi-threaded slave behavior has been greatly improved in MySQL 5.7 too, the biggest example being that you can now instead use (Lamport) logical clock based parallelization:
Replication Slave Options and Variables --slave-parallel-type
Best Answer
You can indeed use stored procedures to refresh the data in your database. It just means coding the INSERTs and UPDATEs appropriate to your data.
If you are replacing the existing data with new data, you could use:
INSERT INTO ... SELECT FROM
... syntax, after deleting the existing data, to pull the data from your query and insert it into the now empty table. Of course, you could run individual steps to update many tables, one at a time.Syntax documentation on
INSERT INTO ... SELECT FROM
is here: https://dev.mysql.com/doc/refman/5.7/en/insert-select.htmlIf you want to
UPDATE ... SELECT FROM
for only some values in a table, you could follow the different examples here:https://stackoverflow.com/questions/1262786/mysql-update-query-based-on-select-query
Also general
UPDATE
syntax is described here: https://dev.mysql.com/doc/refman/5.7/en/update.html