Sep
24
MySQL performance tunning thoughts
Filed Under MySQL | Leave a Comment
There are a lot of posts and discussions on the matter, but here are some tips:
- replacing distinct with a group by on an unique column can/would speed up the query quite a lot
- there is a variable called query_cache_min_res_unit. Use: show status like ‘qc%’; in the mysql console and especially check the Qcache_lowmem_prunes. If there are a lot of them, it means that the memory gets fragmented, as min_res_units are too big. Gives quite a big performance penalty, especially under a lot of concurrent requests and a cache invalidation
- some order by queries might be improved by using force index(…) with the proper index. Sometimes, it clears the filesort that gets used by default.
Jun
2
Writing dynamic fixtures in Symfony
Filed Under Symfony | Leave a Comment
Whenever writing dynamic fixtures in Symfony, be careful about putting new line characters, after each property, but not after the main object declaration. Second, make sure you don’t start with any whitespace, and that the entire yml file does not contain unnecessary new lines or spaces. To debug, simply enable query logging in your database, and you’ll see that, when something is wrong, parts of the query will be mushed-up. Simple example (just look where “\n” is and where it isn’t):
Oct
2
I’ve stumbled across a weired problem in Symfony, using Doctrine. Whenever I wanted to use a leftJoin, stuff would fail. So, here are some tips to help you pass this problems:
1. Check that the leftJoin is issued like $q->(a.RelationshipName r);
where “a” is the root alias of the query, RelationshipName is the NAME of the relationship defined in the yaml file of the database.
2. Make sure you use the actual relationship name from the yaml DB schema, and not the class name or something else. For instance, let’s say you have 2 classes: MysiteArticle and MysiteCategory. To fetch articles, you would build your query like: Doctrine_Query::create()->from(’MysiteArticle a’);
But, to fetch articles together with the category, you would do something like:
Doctrine_Query::create()->from(’MysiteArticle a’)->leftJoin(’a.Category c’); if your relationship name is “Category”, in the schema.yml, or Doctrine_Query::create()->from(’MysiteArticle a’)->leftJoin(’a.MysiteCategory c’); if your relationship name is MysiteCategory.
Dec
18
Getting the cursor position inside a text-field and smart ways to build form validators
Filed Under JavaScript, Uncategorized | 1 Comment
I have always wanted a nice clean way to build form validators based on any kind of rule i would choose, however most of the times I stumbled upon a simple problem: How to get the cursor position inside a text-field? It’s easy in Mozilla, but what about IE?
The challenge was weird, but I finally got a way around, starting an idea here.
What I’ve done is I used Prototype to extend the Form Element Methods and simply add a version of selectionStart and selectionEnd for IE. After that, I just put them to work in a nice input wrapper class.
Read more
Dec
18
Quick quide to regular expressions in JavaScript
1. The form of an expression:
var a = /dog/gim
//dog = the expression to match, g = search all matches, i = case insensitive, m=multiple line
The cool thing is that /dog/ is an object, so you can, for example, do something like /dog/.test(something)
Read more