Hi!
I have a query that as to create a temporary table to execute. The problem is that this table is ALWAYS created on disk!
First of all (because that will be your first guess), here are my server-variables:
tmp_table_size=512M
max_heap_table_size=512M
version : 3.23.54-nt
OS : win2OOO
So the server should not create a disk-based tmp table if its size is not grater than that, right?
Now the query (simplified for clarity, but still producing the behaviour) :
SELECT cellules.indexcellulecommerce
FROM cellules INNER JOIN commerces
ON (cellules.indexcellulecommerce=commerces.indexcellulecommerce)
WHERE cellules.codesite="SIT7401001" AND commerces.codesite="SIT7401001"
GROUP BY cellules.indexcellulecommerce
...and the result of the 'explain' :
table;type;possible_keys;key;key_len;ref;rows;Extra
cellules;ref;CodeSite,IndexCelluleCommerce;CodeSite;21;const;751; "where used, Using temporary"
commerces;ref;CodeSite,IndexCelluleCommerce;IndexCelluleCommerce;5;cellules.IndexCelluleCommerce;20;"where used"
So as you can see, the number of rows scanned is at most 751*21 = ~15000 rows, and the only fields needed for this query are codesite (21 length) and indexcellulecommerce (5 length). So the query can definitely not exceed the tmp_table size.
Now the next point : there is no temporary table created (not even in memory) if I remove the GROUP BY clause! So why does this GROUP BY have to be executed on a disk based temporary table??? I have 2GB of RAM on my Win2k server, and it looks like mysql doesn't want to use them!
Thanks a lot for any suggestion!
Arnaud
I have a query that as to create a temporary table to execute. The problem is that this table is ALWAYS created on disk!
First of all (because that will be your first guess), here are my server-variables:
tmp_table_size=512M
max_heap_table_size=512M
version : 3.23.54-nt
OS : win2OOO
So the server should not create a disk-based tmp table if its size is not grater than that, right?
Now the query (simplified for clarity, but still producing the behaviour) :
SELECT cellules.indexcellulecommerce
FROM cellules INNER JOIN commerces
ON (cellules.indexcellulecommerce=commerces.indexcellulecommerce)
WHERE cellules.codesite="SIT7401001" AND commerces.codesite="SIT7401001"
GROUP BY cellules.indexcellulecommerce
...and the result of the 'explain' :
table;type;possible_keys;key;key_len;ref;rows;Extra
cellules;ref;CodeSite,IndexCelluleCommerce;CodeSite;21;const;751; "where used, Using temporary"
commerces;ref;CodeSite,IndexCelluleCommerce;IndexCelluleCommerce;5;cellules.IndexCelluleCommerce;20;"where used"
So as you can see, the number of rows scanned is at most 751*21 = ~15000 rows, and the only fields needed for this query are codesite (21 length) and indexcellulecommerce (5 length). So the query can definitely not exceed the tmp_table size.
Now the next point : there is no temporary table created (not even in memory) if I remove the GROUP BY clause! So why does this GROUP BY have to be executed on a disk based temporary table??? I have 2GB of RAM on my Win2k server, and it looks like mysql doesn't want to use them!
Thanks a lot for any suggestion!
Arnaud