MySQL is slow?

20 novembre 2018


Daniel Lemire

3 mars 2018

Un autre blogue que je recommande fortement est celui de Daniel Lemire (pas l’humoriste mais bien l’informaticien!).  Il y traite souvent d’algorithmes et de performance avec une minutie du détail inouïe.

Pour avoir un bon exemple de son style et des sujets qu’il traite, je vous suggère son billet sur le choix aléatoire de nombre distinct (Picking distinct numbers at random: benchmarking a brilliant algorithm) ainsi que son article intitulé Iterating over set bits quickly.

Finalement, un exemple de ses contributions à l’open source, les RoaringBitmap.



MySQL, restore et performance!

28 février 2018

Une analyse sérieuse des façons d’optimiser la vitesse d’un RESTORE en MySQL.

Group by de 4 manières

12 février 2018

Différentes subtilités du GROUP BY en MySQL expliquées pour chacune des 4 versions.  Variations sur un même thème expliquées ici!

That guy

3 avril 2017

We all know that guy. You know, that guy who sees performance improvements everywhere, all the time?

That programmer who squeezes everything into bitmaps because « it’s so much faster » ?  And when I say everything, I mean everything! Even if your class only has one flag!

That guy who caches everything in the application because « that’s the optimal way to do it« ?  Even if the data that is cached is just accessed only one time?

That guy who fits a date into an integer in the database because « it’s so much more compact » ?  There goes all your SQL and date functions!

That developer who always ends up re-implementing another sorting algorithm because he read a « great paper » on the subject and « it’s proven that it’s 0.2% faster than the default sort » available?  And after an insane debugging session, you finally realize he has overriden SortedCollection>>#sort: ?  And that his code just doesn’t work properly!

You know, that guy with a C/C++ background who spends countless hours optimizing everything not realizing he has to « make it work » first! You know, that guy who still doesn’t get that often times you only need to optimize very small parts of an application to make a real difference?

You know that guy with strange concepts such as « defensive programming » who tells you nobody ever caught a bug in his code in production? You know, that guy who came up with the « clever » catch-everything method #ifTrue:ifFalse:ifNil:onError:otherwise: ?

You know that guy who never works for more than 4 months at the same place because « they didn’t get it, they’re a bunch of morons » ?

You know, that guy who prefers to implement complex database queries with a #do: loop and a gazillion SELECT statement because « SELECT statements with a 1-row lookup are very optimized by the database server » instead of using JOINs. And then he blames the slow response time of his « highly optimized » data retrieval code on the incompetence of the DBAs maintaining the database?

You know, that guy who once told me « inheritance in Smalltalk is very bad because the deeper the class in the hierarchy, the slower the method lookup is going to be » so that’s why he always preferred « flattened hierarchies » (meaning promoting ALL instance variables into one root class) with 2-3 levels deep in the worst case? « Besides, my code is easier to understand and debug since everything is in one place« .

Well, I was going through some of the sh*ttiest code I’ve seen in a long time last night and I remembered that guy and his ideas about « highly optimized flattened hierarchies » and thought I’d measure his theory!  Here’s the script.

Basically, it creates a hierarchy of classes (10000 subclasses) and times message sends from the top class and the bottom class to measure the difference.

Well, that guy was right… There’s a 1 millisecond difference over 9 million message sends from the root class as compared to the 10000th class at the bottom of the hierarchy.

I wanted to tell that guy he was right but his email address at work is probably no longer valid…

CAVEAT: Make sure you do not have a category with the same name as the one in the script because the script removes the category at the end (and all classes in it!).  Also, be warned it takes a very very very long time to execute!

P.S. All the stories above are real. No f*cking kidding!  Those guys really existed : I’ve worked with them!

La performance de votre queue

19 mars 2017

Ça y est?  J’ai toute votre attention? :)

Ces temps-ci je planche sur un problème relié à la performance de queues de messages (file d’attente de messages, file de messages, message queue).  Heureusement, plutôt que d’avoir à expérimenter par essais et erreurs ou à simuler le système final, les mathématiques sont venues à la rescousse.

Deux articles hyper-utiles sur la performance des queues de messages : le premier ici et le second ici.

Et pour ceux que ça intéresse, il est également possible de télécharger gratuitement un document PDF sur le sujet ici.

Compiler magic

22 février 2017

How do you efficiently divide by 19? All you need is some compiler magic!  It’s all explained here!