# Replication : How to load balance queries ?

**URL:** <https://forums.percona.com/t/replication-how-to-load-balance-queries/168>\
**Category:** Other MySQL® Questions\
**Created:** [January 10, 2007, 8:48am UTC](https://forums.percona.com/t/replication-how-to-load-balance-queries/168 "2007-01-10T08:48:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![delirii](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@delirii](https://forums.percona.com/u/delirii)\
**Post date:** [January 10, 2007, 8:48am UTC](https://forums.percona.com/t/replication-how-to-load-balance-queries/168/1 "2007-01-10T08:48:51Z")

</div>

ng One table VAL\_FAKTA\_VH containing 5.000.000 rows and one table VAL\_DIM\_AVTAL containing 34 rows. The query takes 15 s using Index and 7 s not using index, how is this possible!!! It is not a question about IO, no IOWAIT but alot of CPU 99% (on machines with single CPU and 49.9 om machines with 2 CPU, MySQL does not seems to utilize both CPU:s)

HW  
2\*2Ghz CPU  
8G RAM

I have used huge-conf with the following add:  
join\_buffer\_size 131072  
key\_buffer\_size 3221225472  
tmp\_table\_size 67108864  
read-only  
and some more

DB:  
VAL\_FAKTA\_VH.MYD ~ 600M  
VAL\_FAKTA\_VH.MYI ~ 400M  
VAL\_DIM\_AVTAL.MYI ~ 2M  
VAL\_DIM\_AVTAL.MYD ~ 1M

mysql\> explain SELECT avtal.avtal, sum(utfallkronor) FROM VAL\_FAKTA\_VH V force index(Index\_\_avtalid)

---

<div class="post-metadata">

**Author:** ![Peter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/peter/32/2_2.png) [@Peter](https://forums.percona.com/u/Peter)\
**Post date:** [January 10, 2007, 12:35pm UTC](https://forums.percona.com/t/replication-how-to-load-balance-queries/168/2 "2007-01-10T12:35:35Z")

</div>

, VAL\_DIM\_AVTAL avtal where V.avtalid = avtal.avtalid and avtal.avtal = ‘Huvud’ group by avtal.avtal;  
±—±------------±------±-----±---------------±------- --------±--------±--------------------±-------±--------- —+  
| id | select\_type | table | type | possible\_keys | key | key\_len | ref | rows | Extra |  
+

---

<div class="post-metadata">

**Author:** ![delirii](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@delirii](https://forums.percona.com/u/delirii)\
**Post date:** [January 11, 2007, 3:35am UTC](https://forums.percona.com/t/replication-how-to-load-balance-queries/168/3 "2007-01-11T03:35:20Z")

</div>

t\_join other questions suffer.  
Should not the optimizer se this and do the appropriate thing in this case? Can the optimizer learn from earlier queries?

Background to problem:  
We will be creating this kind of questions from our Cognos-platform and are kean not to build these kind of exceptions in to our model. The Cognos environment are to be exposed to 1000 end users and these questions are generated by Cognos. In our model now with SQL Server this is not a problem.

Is there a way
