Bastian Albers

Januar 11, 2010

MySQL: MAX_JOIN_SIZE resolution

Abgelegt unter: Uncategorized — Tags:, , — Bastian Albers @ 10:37 pm

Jus in case you ever get this error message:

1104: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok

Let me spare you a possible long search for a solution and no, you don’t have to switch to a different webhost: just try to index some foreign keys in your tables and see if it works. If you do that MySQL does not search the whole table for the linked row. So let’s say table1 has 100 rows where each one has a linked row of table2 through a foreign key foreign_key. So if you do a query like this:

SELECT * FROM table1 LEFT JOIN table2 ON table1.foreign_key = table2.id

mysql does not search all rows of table2 a 100 times. Let me explain again: without an index on foreign_key, if table2 has 1000 rows, mysql searches through 1000 rows 100 times. Put an index into the game and you’ll have 1000 times 1 index lookup.

Dezember 21, 2009

Setting radio button values with jQuery

Abgelegt unter: Uncategorized — Tags:, , — Bastian Albers @ 3:48 pm

Let’s say you have a group of radio buttons on your page:

<input type="radio" checked="checked" value="1" name="rayray"/>
<input type="radio" value="2" name="rayray"/>
<input type="radio" value="3" name="rayray"/>

Now getting the value of the selected radio button is easy with jQuery:

$("input[name='rayray']:checked").val();

You have to use the name attribute, as there are several different radio buttons with the same name. Now setting the value to the third option is a bit tricky, but this works for me:

$("input[name='rayray']").each(function(i) {
	if(i==2)
		$(this).attr('checked', true);
	else
		$(this).attr('checked', false);
});

If anyone has a quicker, more elegant way: feel free to share!

(This is all valid for jquery 1.32)

Powered by WordPress ( WordPress Deutschland )