Sorry if this is a stupid question but new to this so need some help to understand a couple of things. Im currently upgrading mysql to 5.1 so I can use partitions in mysql. My question is if I partition a table, would a partitioned table, including the pruning process, still work on a quering using a join or is partitioning optimal if your just quering the table that has the partitions?
EDIT
Here is an example query:
SELECT event.*,site.* FROM event INNER JOIN site ON event.siteid = site.id
WHERE event.eventdate >= [somedate] AND event.eventdate <= [somedate]
AND event.siteid = [siteid]
And I have partitions setup on the events table using the eventdate field. Would mysql still be able to use the partitions on the events table including the pruning process?
Partioned tables can be used in joins.
Tweak the where clause to include one partition only to get the best performance.
e.g. if you partition by year, you can do a join like:
select * from a
inner join partioned_table p on (p.id = a.id)
where p.year = '2011';
This query will work with and without the where clause, but with the where clause it will be much faster because you are only accessing one partition.
If you access more partitions, MySQL has to use a temporary table to stitch the partitions together before it can do the join.
This kind of defeats the purpose of partitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With