Home » Performance » MySQL » tmp_table_size ignored?
tmp_table_size ignored? [message #330] Tue, 07 November 2006 19:44 Go to next message
vgatto  is currently offline vgatto
Messages: 116
Registered: November 2006
Senior Member
It looks like no matter what I do, one of my queries is always going to disk to create its temp file, instead of creating one in memory, and this is killing my server's performance.

I have an 8G machine running MySQL 4.1.16, and I've set my tmp_table_size=64M and my max_heap_table_size=64M. I've verified these settings using show variables. I'm checking to see if temp files are created by watching Created_tmp_disk_tables and the temp data directory. Temp files are always created, the largest being 20M in my tests, which is way under my settings (and in test I've bumped both the of the table settings from 64M all the way to 4G with no change in behavior).

My query doesn't use BLOB or TEXT fields at all, but is grouping by a VARCHAR. I've read on the forums that VARCHAR is automatically converted to CHAR for HEAP tables, with the cost being a much larger temp table due to the fixed size conversion. Even if I restrict my query to a tiny range of data (like 100 rows between the two tables I'm joining), so that the result set is under 10 rows, it will still create a temp file on disk.

If I change the query to group by an unindexed integer id in one of these tables, this query NEVER creates a disk temp table, even if I increase the source data range to be 10x the size of my original test. Basically, it looks like grouping by varchar equals disk based temp tables. Is anyone else seeing this?

On the bright side, using tmpfs does help the performance considerably, but it's not my preferred solution (and neither is normalizing my character data by some integer id).


Re: tmp_table_size ignored? [message #331 is a reply to message #330 ] Wed, 08 November 2006 01:41 Go to previous messageGo to next message
inner  is currently offline inner
Messages: 13
Registered: November 2006
Location: Lithuania
Junior Member
Hi, Vince

I can only confirm I'm having the same problem (and if I'm not mistaken - with MySQL 5.0 too). This actually is pretty strange and I could not find any better solution than using tmpfs yet.. I'd appreciate any hints too.


// Aurimas
Re: tmp_table_size ignored? [message #334 is a reply to message #331 ] Wed, 08 November 2006 04:18 Go to previous messageGo to next message
toasty  is currently offline toasty
Messages: 19
Registered: August 2006
Location: UK
Junior Member
Hi Folks,

Temp tables are always created on disk if they use columns types that the in-memory temp table type (HEAP/MEMORY) doesn't support. Let me see if I can find something on this...

OK, so this http://dev.mysql.com/doc/refman/4.1/en/memory-use.html page says:

"Temporary tables with a large row length (calculated as the sum of all column lengths) or that contain BLOB columns are stored on disk."

No idea what 'large' means in this case though.

There is a better explanation of this online somewhere, can't find it just at the mo though..

The trick (apart from putting your tmp dir on a ramdisk) is to try to remove blobs etc from getting in your tmp tables as part of the query. Usually not possible though I know...



HTH,
Toasty

[Updated on: Wed, 08 November 2006 04:19]

Re: tmp_table_size ignored? [message #356 is a reply to message #330 ] Sun, 12 November 2006 22:48 Go to previous message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Can you create repeatable example for this problem ?

It is possible it is simply some kind of bug, or it is possible there is something which causes your query to implicitely use TEXT/BLOB result column.


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Previous Topic:Problems getting ORDER BY to use index
Next Topic:sort in client lang (php) instead of mysql
Goto Forum:
  


Current Time: Sat Nov 7 09:20:07 EST 2009

Total time taken to generate the page: 0.02702 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.